我有json數據,我希望它通過過濾器如流派顯示。 最後一個問題從How to filter JSON-Data with AngularJs?不工作給我。如何過濾JSON數據與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>
做我丟失somethink? 謝謝..
apps [0] .genre應該是apps.genre – dandavis
哇,謝謝.. 它適用於我。他們兩個.. :)) –