Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 未知提供程序:后提供程序<;-邮递_Angularjs_Ruby On Rails 4 - Fatal编程技术网

Angularjs 未知提供程序:后提供程序<;-邮递

Angularjs 未知提供程序:后提供程序<;-邮递,angularjs,ruby-on-rails-4,Angularjs,Ruby On Rails 4,我不熟悉angular,在尝试从rails后端检索博客文章列表时遇到了这个异常。 谁能帮帮我吗?我找不到这个问题的确切解决办法 Error: [$injector:unpr] Unknown provider: PostProvider <- Post http://errors.angularjs.org/1.2.22/$injector/unpr?p0=PostProvider%20%3C-%20Post 添加Post factory(服务)或将其从PostListCtr依赖项中删除

我不熟悉angular,在尝试从rails后端检索博客文章列表时遇到了这个异常。 谁能帮帮我吗?我找不到这个问题的确切解决办法

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

添加Post factory(服务)或将其从PostListCtr依赖项中删除,您的
Post
提供商在哪里?
//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' }
  })
}]);