function(items){
var res = [];
angular.forEach(items,function(item){
if (item.get) res.push(item);
});
return res;
};angular.forEach( 配列 , 関数 );
※リストが表示されない場合
AddBlockなどの広告ブロックツールがONになっているとリストなどが表示されない場合があります。これらのツールをOFFにしてみてください。
var myapp = angular.module('myapp',[]);
var helo = myapp.controller('HeloController',
function(){
this.count = 0;
this.data = [
{id:0,name:'no data',price:0,get:false},
{id:1,name:'Android phone',price:7800,get:true},
{id:2,name:'New iPhone',price:549020,get:true},
{id:3,name:'windows phone',price:38765,get:true},
{id:4,name:'firefox phone',price:14370,get:true},
{id:5,name:'blackberry phone',price:-123,get:false},
];
this.getData = function(){
return this.data[this.count].id + ': ' +
this.data[this.count].name + ', ' +
this.data[this.count].price + '.';
};
}
);
//getをチェックし、trueのものだけを返す
helo.filter('getRepeat',
function(){
return function(items){
var res = [];
angular.forEach(items,function(item){
if (item.get) res.push(item);
});
return res;
};
}
);
| << 前へ | 次へ >> |