2014-09-27 47 views
-1

我是新来的角,面对这个异常,当试图从rails后端检索博客文章的列表。 任何人都可以帮助我,我无法找到这个问题的确切解决方案。未知的提供者:PostProvider < - Post

Error: [$injector:unpr] Unknown provider: PostProvider <- Post 
http://errors.angularjs.org/1.2.22/$injector/unpr?p0=PostProvider%20%3C-%20Post 

VAR对myApp = angular.module( 'Emangu',[ 'ngRoute', 'ngResource']);

//Routes 

myApp.config([ 
    '$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) { 
    $routeProvider.when('/blog', { 
     templateUrl: '/templates/posts/index.html', 
     controller: 'PostListCtr' 
    }); 
    } 
]); 

//Controllers 

myApp.controller("PostListCtr", ['$scope', '$http', '$resource', 'Posts', 'Post', '$location', function ($scope, $http, $resource, Posts, Post, $location) { 

    alert("hello"); 
    $scope.posts = Posts.query(); 
    $scope.deletePost = function (Post) { 
     if (confirm("Are you sure you want to delete this Post?")) { 
      Post.delete({ id: Post }, function() { 
       $scope.posts = Posts.list(); 
       $location.path('/'); 
      }); 
     } 
    }; 
}]); 

//resources 

myApp.factory('Posts', ['$resource', function ($resource) { 
    return $resource('/posts.json', {}, { 
    query: { method: 'GET', isArray: true }, 
    create: { method: 'POST' } 
    }) 
}]); 
+1

哪里是你的'POST'提供商删除呢? – Shomz 2014-09-27 11:31:20

回答

1

添加后厂(服务)或从PostListCtr依赖

相关问题