Rectangle 27 0

javascript Angular Js binding text input with model?


<p><span ng-show="message.text != ''">Hello, </span>{{message.text}}</p>
<p>{{message.text && 'Hello, '+message.text || message.text}}</p>
<p>{{message.text ? 'Hello, ' + message.text : message.text}}</p>

@ShivangSarawagi You might like using Angular's ngShow or ngHide directive.

Ofcourse you can. But why to do that when there's a very simpler way of doing the same?

Update: You can use ngShow if you want to conditionally display an element:

can I use jquery for DOM manipulation with angularJS? like instead of ternary operator use the jquery hide, show method?

thanks for the reply; can u plz explain why && and || are used; is there any link from where I can refer. message.text will display whatever the user types then after that will the && do?

Note