Angular delimiter Watch with filtering
Angular delimiter Watch
by Andrew Pougher
HTML
<div ng-app="app" ng-controller="mainCntrl">
<input ng-model="searchinput"/>
<p>{{names}}</p>
</div>
<script>
/* http://bit.ly/ARP71 */
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-4809804-1', 'auto');
ga('send', 'pageview');
</script>
JavaScript
var andrewsAPP = angular.module('app', []);
andrewsAPP.controller("mainCntrl", function ($http, $scope , $sce, $templateCache, $window,$location){
$scope.menuItems = [
{'name': 'Andrew', isOn: 1},
{'name': 'Pougher', isOn: 0},
{'name': 'Oh YEH', isOn: 1},
{'name': 'Andrew Other Things', isOn: 1},
];
$scope.$watch('menuItems|filter:{isOn:1}|filter:searchinput', function(menuItems) {
$scope.names = menuItems.map(function(item) { return item.name }).join(';');
});
});//end all