检查JSON属性的值,然后只将某些对象传递到$scope?
我在Angular中有一个/xyz/:id路由和控制器,它被设置为与提供JSON的$resource一起工作检查JSON属性的值,然后只将某些对象传递到$scope?,json,angularjs,Json,Angularjs,我在Angular中有一个/xyz/:id路由和控制器,它被设置为与提供JSON的$resource一起工作 angular.module('MyApp') .controller('DetailCtrl', ['$scope', '$routeParams','Results', function($scope, $routeParams, Results) { Results.get({ _id: $routeParams.id }, function
angular.module('MyApp')
.controller('DetailCtrl', ['$scope', '$routeParams','Results',
function($scope, $routeParams, Results) {
Results.get({ _id: $routeParams.id }, function(result) {
$scope.result = result;
});
}]);
结果来自一个与此类似的模型:
resultsSchema = new Schema ({
_id: Number ,
name: String,
...
events: [{
_id: Number,
type: String,
...
}]
});
事件数组中的类型是一个字符串,包含我知道的一组值。比如黄牌、进球等等
我想说这样的话来得到这个想法:
$scope.goals = result.events
where result.events.type == 'goal'
我怎样才能做到这一点 谢谢你的引导。我试过了,但似乎不起作用。ng repeat=result.match_events | filter:{type:'goal'}哈哈,它能用。我在看一个页面,页面上没有匹配过滤器的元素。检查了另一个,一切正常。谢谢