Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
466 views
in Technique[技术] by (71.8m points)

javascript - 无法实例化模块[$ injector:unpr]未知提供者:$ routeProvider(Failed to instantiate module [$injector:unpr] Unknown provider: $routeProvider)

从AngularJS 1.0.7升级到1.2.0rc1时收到此错误。

  ask by Scotty.NET translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The ngRoute module is no longer part of the core angular.js file.(ngRoute模块不再是核心angular.js文件的一部分。)

If you are continuing to use $routeProvider then you will now need to include angular-route.js in your HTML:(如果您继续使用$ routeProvider,那么您现在需要在HTML中包含angular-route.js :) <script src="angular.js"> <script src="angular-route.js"> API Reference(API参考) You also have to add ngRoute as a dependency for your application:(您还必须添加ngRoute作为应用程序的依赖项:) var app = angular.module('MyApp', ['ngRoute', ...]); If instead you are planning on using angular-ui-router or the like then just remove the $routeProvider dependency from your module .config() and substitute it with the relevant provider of choice (eg $stateProvider ).(如果您打算使用angular-ui-router等,那么只需从模块.config()删除$routeProvider依赖项,并将其替换为相关的选择提供程序(例如$stateProvider )。) You would then use the ui.router dependency:(然后,您将使用ui.router依赖项:) var app = angular.module('MyApp', ['ui.router', ...]);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...