Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. angular.module("app", []).
  2. filter('department', function(filterFilter) {
  3. return function(items, args) {
  4. var productMatches;
  5. var output = [];
  6. var count = 0;
  7.  
  8. if (args.selectedDepartment.Id !== undefined && args.option) {
  9. for (let i = 0; i < items.length; i++) {
  10.  
  11. productMatches = items[i].products.filter(function(el) {
  12. return el.Order__r.Department__r.Id === args.selectedDepartment.Id;
  13. });
  14.  
  15. if (productMatches.length !== 0) {
  16. output[count] = {};
  17. output[count].products = productMatches;
  18. output[count].firstProduct = items[i].firstProduct;
  19. count++;
  20. }
  21.  
  22. }
  23. }
  24. return output;
  25. };
  26. }).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement