为什么在渲染视图时抛出了以下错误
未捕获错误:[$ injector:modulerr]无法实例化模块 registrationModule由于:错误:[$ injector:unpr]未知提供者: $ routeProvider http://errors.angularjs.org/1.5.0/ $注射器/ unpr?P0 =%24routeProvider 在http://localhost:2044/Scripts/angular.js:68:12 在http://localhost:2044/Scripts/angular.js:4397:19 at getService(http://localhost:2044/Scripts/angular.js:4550:39) at injectionArgs(http://localhost:2044/Scripts/angular.js:4574:58) at Object.invoke(http://localhost:2044/Scripts/angular.js:4596:18) at runInvokeQueue(http://localhost:2044/Scripts/angular.js:4497:35) 在http://localhost:2044/Scripts/angular.js:4506:11 at forEach(http://localhost:2044/Scripts/angular.js:321:20) 在loadModules(http://localhost:2044/Scripts/angular.js:4487:5) 在createInjector(http://localhost:2044/Scripts/angular.js:4409:19) http://errors.angularjs.org/1.5.0/ $注射器/ modulerr P0 = registrationModule&安培;?... JECTOR%20(HTTP%3A%2F%2Flocalhost%3A2044%2FScripts%2Fangular.js%3A4409%3A19)
这是我的route configuration
var registrationModule = angular.module("registrationModule", [])
.config(function($routeProvider, $locationProvider) {
$routeProvider.when('/Registration/Courses', { templateUrl: '/templates/courses.html', controller: 'CoursesController' });
$routeProvider.when('/Registration/Instructors', { templateUrl: '/templates/instructors.html', controller: 'InstructorsController' });
$locationProvider.html5Mode(true);
});
我在MVC5中使用 Angular JS
答案 0 :(得分:3)
您需要包含'ngRoute'。
var registrationModule = angular.module("registrationModule", ['ngRoute'])
.config(function($routeProvider, $locationProvider) {
$routeProvider.when('/Registration/Courses', { templateUrl: '/templates/courses.html', controller: 'CoursesController' });
$routeProvider.when('/Registration/Instructors', { templateUrl: '/templates/instructors.html', controller: 'InstructorsController' });
$locationProvider.html5Mode(true);
});