html - how to create Custom filter angularjs javascript controller side? -
How to create custom filter angular javascript controller side? I want to search by SegmentId in the array in the segment, to create a filter that filters the segment separated from the segment ID -
// control $ scope.GetSegmentDetails = function (id) { $ Scope. Calculation Name = $ Filter ('Segment BIID') ($ Scope Section, ID); } // Filter app.filter ('Segment BIID', function) (return function (input, search pricing) {if (Search!) Return input; var results = []; angular (for input, function (person) { }}; Return result;}
})
You do not have to type your filter to filter by Segment ID
Here you have an example
function micrification ($ radius, $ filter) {$ scope.data = [ {"Segment ID": "1", "{" Segment ID ":" 2 "," Description ":" HID passive "}, {" Segment ID ":" 3 "," Details ":" hod testup "}, {"Segment ID": "8", "Details": "" "" "" "" "" "" "" "" "" "," Details ":" Details ":" hod "Hood welcome back"}] $ scope.filterData = {"Segment ID": "12", "Details": "hod request"}, {"Segment ID": "13", "Details" Function (segmentId) {return $ filt ( 'Filter') ($ scope.data, {Segment ID: Khandaidi}); }}
& lt; Script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> & Lt; Div ng-app ng-controller = "MyCtrl" & gt; Completed: & lt; Ul & gt; & Lt; Li ng-repeat = "segments in data" & gt; {{Segment. Segment id}} & lt; / Li & gt; & Lt; / Ul & gt; Perforated in view: & lt; Ul & gt; & Lt; Li ng-repeat = "Segment in data: filter: {Segment id: 1111}" & gt; {{Segment. Segment id}} & lt; / Li & gt; & Lt; / Ul & gt; Controller in the admin: & lt; Ul & gt; & Lt; Li ng-repeat = "segments in filter data (1111)" & gt; {{Segment. Segment id}} & lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt;
Comments
Post a Comment