0

I want to extend one filter function which used to enable/disable a button.

I have an array and am receiving a variable (serviceVariable) from a service. I am looping through this array to check whether this service value is available or not. if match, then filter function should return true to disable a button.

But service takes some time to update this serviceVariable, so on page load it is not matching with any of array variables. but after few seconds am receiving the serviceVariable with value.

can we use watch here? so that when my serviceVariable get update, I can check with new value.

or any other way?

1 Answer 1

0

You should try invoking filter from javascript, means from controller or service in the service call response.

So the thing is you need to call your filter asynchronously (i.e after making service call) in your js file. So call your filter in your js file like the following syntax,

$scope.isButtonShown = $filter('filtername')(arg1,arg2); // return true or false from filter which would dynamically show or hide the button

Hope this helps

For references :

How to use a filter in a controller?

How to use a filter in javascript instead of the Html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.