AngularJS 1.2 $ injector:modulerr
发布时间:2020-12-17 09:23:25 所属栏目:安全 来源:网络整理
导读:当使用angular 1.2而不是1.07下面的代码片段是无效的,为什么? 'use strict';var app = angular.module('myapp',[]);app.config(['$routeProvider','$locationProvider',function($routeProvider,$locationProvider) { $locationProvider.html5Mode(true);
当使用angular 1.2而不是1.07下面的代码片段是无效的,为什么?
'use strict'; var app = angular.module('myapp',[]); app.config(['$routeProvider','$locationProvider',function($routeProvider,$locationProvider) { $locationProvider.html5Mode(true); $routeProvider. when('/',{ templateUrl: 'part.html',controller: 'MyCtrl' }). otherwise({ redirectTo: '/' }); } ]); 问题是在注入器配置部分(app.config): Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.0rc1/$injector/modulerr?p0=muninn&p1=Error%…eapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.0rc1%2Fangular.min.js%3A31%3A252) 如果我记得正确这个问题从角1.1.6开始。
该问题是由于缺少ngRoute模块的引入。从版本1.1.6它是一个单独的部分:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular-route.min.js"></script> var app = angular.module('myapp',['ngRoute']); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |