Hello Santiwijoyo
i first made a filter
angular.module('timers').filter('filterww',[ 'appdata', function(appdata){
return function(input,search,timerscontroller){
var out = [];
angular.forEach(input, function(timer){
if(search)
var descriptionLC = timer.description.toLowerCase();
searchLC = search.toLowerCase();
if(descriptionLC.match(searchLC)){
out.push(timer);
}
});
return out;
};
in my *view* i put an *input* with an *ng-change* attached to it that
calls the filterTimers() function located in my controller
<input type="text" ng-model="timersCtrl.appdata.timer.queryww"
placeholder="Description" data-ng-change="timersCtrl.filterTimers()">
*function in controller:*
self.filterTimers = function(){
var filter = function(){
self.filteredTimers = $filter('filterww')(self.appdata.timers,
self.appdata.timer.queryww, self);
};
};
I've stripped some irrelevant code from the example, i don't consider
myself an expert yet so if anyone finds an error in this way of thinking
please let us know.
hope this helps you
Gr
Marco
2015-12-03 6:24 GMT+01:00 Santiwijoyo Salim <[email protected]>:
> Hi Marco,
>
> I am trying to do what Marco instructed which is to move the filtering
> part into a function to have less logic in template with no luck.
>
> Can you provide me with a sample how you manage to do this?
>
> Regards,
> Santiwijoyo
>
>
> On Friday, April 24, 2015 at 12:59:20 PM UTC+8, Marco wrote:
>>
>> Hello Sander,
>> Thanks for pushing me in The right direction, now i use my filter in the
>> function called by ngChange and iT works.
>>
>> At first i tried to put The Logic of my filter in that function but that
>> gave me problems because of The resource object, The filter takes care of
>> this.
>>
>> Thanks again!
>>
>> Gr Marco
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "AngularJS" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/angular/3QGdSHtpyY0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>
--
Groeten
Marco
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.