I want to use checkboxes with custom angularjs filter. Code that I'm using so far is on plunkr.
http://plnkr.co/edit/hoSaaim9sY8AOUd4inLJ
I have nested json array to store data. With angular forEach method I get an array of technologies and then flatten it and remove duplicate items to create an array called "techStack". Here is my controller:
angular.module('app', []);
function getUnique(inputArray){
var outputArray = [];
for (var i = 0; i < inputArray.length; i++){
if ((jQuery.inArray(inputArray[i], outputArray)) == -1){
outputArray.push(inputArray[i]);
}
}
return outputArray;
}
app.controller('CompaniesController', ['$scope', '$http',
function($scope, $http) {
$http.get('companies.json').success(function(data) {
$scope.companies = data;
var techStackUnsorted = []
var merged = [];
$scope.techStack = [];
angular.forEach(data, function(company, technologies) {
var tech = company.technologies;
techStackUnsorted.push(tech);
})
merged = getUnique(_.flatten(techStackUnsorted));
$scope.techStack = merged;
})
}
]);
So, I need to filter companies with checkboxes by "technology"
I've read several solutions like this Filter Array Using Checkboxes with AngularJS or this How to use checkbox to filter results with Angular? but failed to make it work with my app as I'm using different arrays with ng-repeat. How can I make this work?
NOTE: seems like it doesn't load json in this plunkr, can't figure out why.
EDIT: forgot to add actual plunkr link, added it now