使用角度js时出错:[$ injector:unpr]和[$ injector:nomod]

时间:2014-11-12 08:36:27

标签: javascript angularjs

使用角度js。当我使用此代码时出现错误,"未捕获错误:[$ injector:nomod]发生

 angular.module('app1')
.provider('Post',function(){
 this.$get = ['$resource', function ($resource) {
 var Post = $resource('http'://localhost:7214/Admn/University.aspx?/api/post/:_id', {}, {
update: {
method: 'PUT'
}
})
return Post;
}];
});
angular.module('app1')
.controller('MainCtrl', ['$scope', '$route', 'Post', function ($scope,     $route, Post) {
$scope.post = new Post();
$scope.posts = new Post.query();
$scope.newPost = function () {
$scope.post = new Post();
$scope.editing = false;
}

当我添加' ngRoute'在我的模块中然后发生此错误,"错误:[$ injector:unpr]。此错误的代码是

angular.module('app1',['ngRoute'])
.provider('Post',function(){
this.$get = ['$resource', function ($resource) {
var Post = $resource('http'://localhost:7214/Admn/University.aspx?/api/post/:_id', {}, {
update: {
method: 'PUT'
}
})
return Post;
}];
});
angular.module('app1','[ngRoute]')
.controller('MainCtrl', ['$scope', '$route', 'Post', function ($scope,     $route, Post) {
$scope.post = new Post();
$scope.posts = new Post.query();
$scope.newPost = function () {
$scope.post = new Post();
$scope.editing = false;
}

以下是我项目中包含的文件。

<script src="/Scripts/Jquery.js"></script>
<script src="/Scripts/angular.js"></script>
<script src="/Scripts/angular-ng-grid.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7    /angular-    resource.min.js"> </script>
<script src="/Scripts/angular-route.min.js"></script>

注意:在上面的代码中,我使用了&#39; http:&#39;然后是其余的链接。这是因为stackoverflow给出了链接错误。在我的项目中,我使用了原始的链接模式。&#39; http:/.... /。&#39;

0 个答案:

没有答案