Angular.js Unknown provider 错误

var Todoapp = angular.module("Study", ["ngResource"]).config(function ($routeProvider) {
    $routeProvider.
        when("/", { controller: ListCtrl, templateUrl: "list.html" }).
        otherwise({redirectTo:"/"});
});

var ListCtrl = function ($scope,$location) {
    $scope.test = "testing";
}
上面的语句运行时会报 Uncaught Error: [$injector:modulerr] Failed to instantiate module Study due to: Unknown provider: $routeProvider

这个错误,需要将 ngResource 改成 ngRoute就可以了


第二个问题:

Uncaught Error: [$injector:modulerr] Failed to instantiate module Study due to:Error:

[$injector:modulerr] Failed to instantiate module ngRoute due to:

Error: [$injector:nomod] Module 'ngRoute' is not available! 

You either misspelled the module na...<omitted>...1)

这个错误是因为没有引用相应JS:    <script src="Scripts/angular-route.js"></script>

你可能感兴趣的:(Angular.js Unknown provider 错误)