【发布时间】:2014-01-22 03:22:52
【问题描述】:
我有 json 数据,我希望它通过流派等过滤器显示。 How to filter JSON-Data with AngularJs? 的最后一个问题对我不起作用。
myapp.js
var myApp = angular.module('myApp', []);
myApp.controller('myApp', function($scope) {
$scope.isoffice = function(apps) {
return apps[0].genre === "office";
};
$scope.apps = [
{
"id": "stardict",
"genre": "aksesoris",
"name": "Stardict"
},
{
"id": "libreoffice",
"genre": "office",
"name": "LibreOffice"
}];
}
我的 index.html
<div ng-repeat="app in apps | filter:isoffice">
{{apps[0].name}}
</div>
我想念什么吗? 谢谢你。。
【问题讨论】:
-
apps[0].genre 应该是 apps.genre
-
哇,谢谢.. 它对我有用。他们俩.. :))
标签: javascript json angularjs