Spearfisher
Spearfisher

Reputation: 8763

Use .split() and ng-show

I am trying to hide/show an alert if a user is using an incorrect account to complete an action. To make it short, my condition is that if his username is not made of a single word, there is a problem.

So far, I am using this in my directive and it works fine:

if (scope.user.displayName.split(" ").length >= 2) $(".preview p.warning").show()

I am trying to make it shorter using directly this:

  <p class="warning" ng-show="user.displayName.split(" ").length >= 2">Are you sure {{ user.displayName }} is your company account?</p>

But it is not working.

How can I fix this?

Thanks

Upvotes: 0

Views: 95

Answers (1)

Satpal
Satpal

Reputation: 133403

Use quotes properly

<p class="warning" ng-show='user.displayName.split(" ").length >= 2'>Are you sure {{ user.displayName }} is your company account?</p>

Upvotes: 2

Related Questions