angular.js - angular js 報錯 [$injector:modulerr] 模塊注入錯誤
問題描述
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: ’這是用戶’ }) $routeProvider.when(’/onlineclasses’, {template: ’這是其他’ }) $routeProvider.when(’/preschedule’, {template: ’這是用戶’ }) $routeProvider.when(’/fireman’, {template: ’這是其他’ }) $routeProvider.when(’/qiangke’, {template: ’這是用戶’ }) $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-’,’’]})
錯誤
問題解答
回答1:
代碼里沒有引入angular-route.js
回答2:
http://m.4tl426be.cn/articl...
看一下上面的教程吧,然后一般這么寫
angular.module(’myapp’, [’ngRoute’]).config([ ’$routeProvider’, function ($routeProvider) {$routeProvider .when(’/home’, {templateUrl: ’home.html’,controller: ’HomeController’ }) .otherwise(’/home’) }])回答3:
app模塊找不到,看看注入什么的
相關(guān)文章:
1. mysql - 把一個表中的數(shù)據(jù)count更新到另一個表里?2. mysql 查詢身份證號字段值有效的數(shù)據(jù)3. node.js - 為什么微信的消息MsgId出現(xiàn)重復(fù)了,無法排重了。。4. mysql的主從復(fù)制、讀寫分離,關(guān)于從的問題5. MySQL 截短某一列的字符串6. 請教使用PDO連接MSSQL數(shù)據(jù)庫插入是亂碼問題?7. mysql - 分庫分表、分區(qū)、讀寫分離 這些都是用在什么場景下 ,會帶來哪些效率或者其他方面的好處8. mysql - 字符串根據(jù)字典替換9. 視頻文件不能播放,怎么辦?10. node.js - nodejs開發(fā)中常用的連接mysql的庫
