Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.controller('TestController', function ($scope, $http, $timeout) {
- $scope.ob = [
- {id: 1, prices: [{count: 2, price: 18}, {count: 3, price: 38}]},
- {id: 2, prices: [{count: 2, price: 18}, {count: 3, price: 38}]},
- {id: 3, prices: [{count: 2, price: 18}, {count: 3, price: 38}]},
- {id: 4, prices: [{count: 2, price: 18}]},
- {id: 5, prices: [{count: 3, price: 18}, {count: 5, price: 38}]},
- {id: 6, prices: [{count: 1, price: 18}, {count: 2, price: 38}]},
- {id: 7, prices: [{count: 4, price: 18}, {count: 1, price: 38}]},
- {id: 8, prices: [{count: 2, price: 18}, {count: 3, price: 38}]}
- ];
- $scope.getByCount = function (count) {
- for (var i in $scope.ob) {
- for (var r in($scope.ob[i].prices)) {
- if (count.indexOf($scope.ob[i].prices[r].count) === -1) {
- delete $scope.ob[i].prices[r];
- }
- }
- }
- $timeout(function () {
- console.log($scope.ob);
- }, 500);
- }
- $scope.getByCount([1, 2]);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement