10

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

1 Answer 1

16

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'}}
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.