AngularJS从$ resource查询请求中获取某些参数

时间:2015-11-01 19:52:14

标签: javascript angularjs angular-formly

我有像$scope.posts = posts.query()

那样检索的对象

帖子是ngResrouce

angular.module('flapperNews')
.factory('posts', ['$resource', function($resource) {
    return $resource('api/posts.json/:id', {id: "@id"})
}]);

检索对象

[
        0: {
            $hasKey: "object:4",
            title: "some text",
            content: "hello world there",
            upvotes: 0
        }
        1: {
            $hasKey: "object:5",
            title: "Lorem ipsum is dolor",
            content: "hello world there",
            upvotes: 0
        }
        2: {
            $hasKey: "object:6",
            title: "When there is nothing to share",
            content: "hello world there",
            upvotes: 0
        }
    ]

我怎样才能获得" title"从这个检索到的对象,所以我可以使用它 AngularJS形式验证? (验证新帖子标题是否唯一)

0 个答案:

没有答案