why angular gives the injector module error?

why when the view is rendered the following error was thrown

Uncaught Error: [$injector:modulerr] Failed to instantiate module registrationModule due to: Error: [$injector:unpr] Unknown provider: $routeProvider http://errors.angularjs.org/1.5.0/$injector/unpr?p0=%24routeProvider at http://localhost:2044/Scripts/angular.js:68:12 at 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) at http://localhost:2044/Scripts/angular.js:4506:11 at forEach (http://localhost:2044/Scripts/angular.js:321:20) at loadModules (http://localhost:2044/Scripts/angular.js:4487:5) at createInjector (http://localhost:2044/Scripts/angular.js:4409:19) http://errors.angularjs.org/1.5.0/$injector/modulerr?p0=registrationModule&…jector%20(http%3A%2F%2Flocalhost%3A2044%2FScripts%2Fangular.js%3A4409%3A19)

here is my 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);
    });

i'm using Angular JS in MVC5


你需要包含'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);
    });
链接地址: http://www.djcxy.com/p/77680.html

上一篇: 错误[$ injector:unpr]注入清理依赖项时

下一篇: 为什么角度给喷油器模块错误?