angular.js - angular js 報(bào)錯(cuò) [$injector:modulerr] 模塊注入錯(cuò)誤
問(wèn)題描述
html
<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <title>Document</title> <script src='angular.min.js'></script> <script src='angular-route.min.js'></script> <script src='app.js'></script> <script src='controller.js'></script> <link rel='stylesheet' href='semantic.min.css'> <link rel='stylesheet' href='index.css'></head><body ng-app='myapp'> <p class='container'><p class='head'> <p class='home'></p> <p class='user-info'><!--<button onclick='alert()'></button>--> </p></p><p class='ui secondary vertical pointing menu leftbar'> <a href='13935.html#/user'> User</a> <a href='13935.html#/comments'> Comments</a> <a href='13935.html#/onlineclasses'> Online Classes</a> <a href='13935.html#/preschedule'> PreSchedule</a> <a href='13935.html#/fireman'> Fireman</a> <a href='13935.html#/qiangke'> 搶課列表</a></p><p class='content'> <p class='content-head'><p class='ui secondary pointing menu'> <a href='13935.html#/user'> Students </a> <a class='item'> Families </a></p> </p> <p ng-view></p></p> </p></body></html>
app.js
var app = angular.module(’myapp’, [’ngRoute’])app.config([’$routeProvider’, function ($routeProvider) { $routeProvider.when(’/user’, {templateUrl: ’user.html’,controller: ’user’ }) $routeProvider.when(’/conmments’, {template: ’這是用戶(hù)’ }) $routeProvider.when(’/onlineclasses’, {template: ’這是其他’ }) $routeProvider.when(’/preschedule’, {template: ’這是用戶(hù)’ }) $routeProvider.when(’/fireman’, {template: ’這是其他’ }) $routeProvider.when(’/qiangke’, {template: ’這是用戶(hù)’ }) $routeProvider.when({redirectTo: ’/user’ });}])
user.html
<p ng-controller='user'> <p class='searchbox'><select ng-options='x for x in gender'></select><select ng-options='x for x in age'></select><select ng-options='x for x in province'></select> </p></p>
controller.js
app.controller(’user’, function ($scope) { $scope.gender = [’-gender-’, ’female’, ’male’]; $scope.age = [’-age-’, ’ < 5 ’, ’6 ’, ’7 ’, ’8 ’, ’ > 8 ’]; $scope.province = [’-province-’,’’]})
錯(cuò)誤
![angular.js - angular js 報(bào)錯(cuò) [$injector:modulerr] 模塊注入錯(cuò)誤](http://www.piao2010.com/attached/image/news/202311/101113af5f.png)
問(wèn)題解答
回答1:
代碼里沒(méi)有引入angular-route.js
回答2:
http://www.piao2010.com/articl...
看一下上面的教程吧,然后一般這么寫(xiě)
angular.module(’myapp’, [’ngRoute’]).config([ ’$routeProvider’, function ($routeProvider) {$routeProvider .when(’/home’, {templateUrl: ’home.html’,controller: ’HomeController’ }) .otherwise(’/home’) }])回答3:
app模塊找不到,看看注入什么的
相關(guān)文章:
1. 我在導(dǎo)入模板資源時(shí)遇到無(wú)法顯示的問(wèn)題,請(qǐng)老師解答下2. 運(yùn)行python程序時(shí)出現(xiàn)“應(yīng)用程序發(fā)生異常”的內(nèi)存錯(cuò)誤?3. thinkphp6使用驗(yàn)證器 信息如何輸出到前端頁(yè)面4. python - sqlalchemy更新數(shù)據(jù)報(bào)錯(cuò)5. javascript - h5微信中怎么禁止橫屏6. PHPExcel表格導(dǎo)入數(shù)據(jù)庫(kù)怎么導(dǎo)入7. macos - 無(wú)法source activate python278. html5 - 前端面試碰到了一個(gè)緩存數(shù)據(jù)的問(wèn)題,來(lái)論壇上請(qǐng)教一下9. html - 網(wǎng)頁(yè)的a標(biāo)簽到底要不要寫(xiě)上域名?10. css - 移動(dòng)端 盒子內(nèi)加overflow-y:scroll后 字體會(huì)變大

網(wǎng)公網(wǎng)安備