0

I could bind text on single condition as this <ion-label>{{company ? company.name : 'Select a company'}}</ion-label>

How ca I use multiple condition in this? like, <ion-label>{{company || organization ? company.name : 'Select a company'}}</ion-label>

5
  • Are you getting any errors? Whay are you using " to wrap interpolation? Commented Jun 18, 2018 at 7:24
  • remove the "" Commented Jun 18, 2018 at 7:25
  • Why are you using " ?? Commented Jun 18, 2018 at 7:25
  • 1
    try to create get property or function and do code in that and use that in your html Commented Jun 18, 2018 at 7:32
  • I am sorry, i don't use " it is <ion-label>{{company ? company.name : 'Select a company'}}</ion-label> Commented Jun 18, 2018 at 7:47

2 Answers 2

1

You should assign to some variable first in controller part like this -

myValue = this.company || this.organization;
<ion-label>{{myValue ? myValue?.name : 'Select a company'}}</ion-label>

PS: Also no need to wrap your variable into interpolation syntax using ".

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

Comments

1

if you have multiple condition then you should make use of function instead of doing it in html

<ion-label>{{getLable(input)}}</ion-label>

getLabel(input){

  return "text";
}

Easy manage complex condition in code file rather then html.

1 Comment

This approach would be much better to avoid complex condition checking on view side (HTML)

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.