So in AngularJS there was a way, in the markup, to bind data to a string like this:
{{myString | 'N/A'}}
What this did was, in one quick swipe, display the string if it wasn't empty. If it was empty, it would display the text behind the pipe.
Now I'm using Angular 2 and I'm trying to do the same thing except I can't seem to find the syntax to do so. Has anyone tried doing this yet? If so, how can I go about it without having to do it in the component level.
Thanks
Single pipe is Bitwise OR is consider as Pipe
in Angular 2 which look up for filter with name after |
symbol. You should be using ||
instead of |
(single pipe).
{{myString || 'N/A'}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With