execute function inside template – Angular 2

Spread the love

In Angular 2, You might wanna execute function inside template, that’s what i am gonna help you guy’s quickly. In Angular 2, Simple template interpolation can be done as follow:

Now what if you simply wanna print “NA” if no value corresponding to above interpolation exist. In that case you can either write a function which take above value and return required result as follow:

Now, you can change above template simply as follow:

In above template, i have applied¬†evalDataFields() inside interpolation. ¬†That’s it for this short Q&A… Happy coding…:)



Leave a Reply

Your email address will not be published. Required fields are marked *