user3323438 user3323438 - 1 year ago 62
AngularJS Question

how to send filtered paramter to a function in angular js?

I want to send filtered date as parameter to my function, fetchData(), i tried something like this, but its giving errors. what is the correct way of doing it?

<button type="button" ng-click="gridDataCtrl.fetchData(,myDate | date:'dd-MM-yyyy')">Refresh</button>

Answer Source

You can do filter in controller


<button type="button" ng-click="gridDataCtrl.fetchData(,myDate)">Refresh</button>

In controller(make sure that you inject $filter):

vm.fetchData = function(name, date){
  date = $filter('date')(date, 'dd-MM-yyyy');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download