"data":[
{"name":"Boots","description":"High Quality football boots","category":"Football","price":500,"id":"28198b61e64abae1"},
{"name":"Jersey Kit","description":"Official team jersey","category":"Fashion","price":1200,"id":"5381a6769985d838"},
{"name":"Bottle","description":"High quality made water bottle","category":"Health","price":20,"id":"f743ce619c57c830"},
{"name":"Gloves","description":"High quality gloves for best GKs in the world","category":"Football","price":650,"id":"9ef69a59000b3838"},
{"name":"Bag","description":"Training kit bag","category":"Training","price":20,"id":"07e192edb2f63aed"},
{"name":"Socks","description":"Best quality","category":"Health","price":60,"id":"d642e7ffa7145b5b"},
{"name":"EPL official match ball","description":"Light weight football","category":"Football","price":75,"id":"7df38a6c46e5f8ef"},
{"name":"Whistle","description":"Light weight for referees","category":"Football","price":5,"id":"0f3d94d798804b4d"},
{"name":"Nets","description":"High quality nets","category":"Training","price":50,"id":"4e3d61a7a124e9db"},
{"name":"Stop watch","description":"Best in quality","category":"Training","price":120,"id":"b86bfb7b0b3c6ac6"}
]
我正在使用AngularJs $filter
,如此:return $filter("limitTo")(data.splice(3),size);
splice()返回一个以索引no 3中的元素开头的数组,而不是从索引no 3中删除元素。请解释。
答案 0 :(得分:0)
您不必使用splice
使用角度filter
,
{{ limitTo_expression | limitTo : limit : begin}}
http://jsfiddle.net/prasanthbendra/qz5xbkn5/
在控制器中,
$filter("limitTo")($scope.data, 3, 3)
查看
{{data | limitTo:3:3}}
答案 1 :(得分:0)
使用角度滤镜的最佳方法
var removeItem = data.filter(function(key,val) { return val < 3; });
var remainingItem = data.filter(function(key,val) { return val >= 3; });
console.log(removeItem);
console.log(remainingItem);