2

I have an

ng-if="dc.emailNotificationSchedule.progressInterval === dc.SkillCompletionProgressIntervals.NEVER_LOGGED_IN".

What i want to do is to have one time bindings for both variables in ng-if. But when i try to use

ng-if="(::dc.emailNotificationSchedule.progressInterval) === (::dc.SkillCompletionProgressIntervals.NEVER_LOGGED_IN)"

angular throws the following error :

Error: [$parse:syntax] Syntax Error: Token ':' not a primary expression at column 2 of the expression [(::dc.emailNotificationSchedule.progressInterval) === (::dc.SkillCompletionProgressIntervals.NEVER_LOGGED_IN)] starting at
[::dc.emailNotificationSchedule.progressInterval) ===
(::dc.SkillCompletionProgressIntervals.NEVER_LOGGED_IN)].

What is the right way ?

Suren Aznauryan
  • 984
  • 10
  • 24

2 Answers2

2

Try this way:

ng-if="::(dc.emailNotificationSchedule.progressInterval === dc.SkillCompletionProgressIntervals.NEVER_LOGGED_IN)"
karaxuna
  • 26,752
  • 13
  • 82
  • 117
  • 1
    this way it will not work as expected, because when either of the properties becomes stable then the expression itself becomes stable(false in this case, as the second argument will be null at that time) and the watcher for the whole expression will be removed. Hence when second property becomes stable it's value will not have any effect on the whole expression result. – Suren Aznauryan Feb 16 '16 at 11:15
  • You can add `dc.emailNotificationSchedule.progressInterval === undefined ? undefined : dc.SkillCompletionProgressIntervals.NEVER_LOGGED_IN === undefined ? undefined : ...` – karaxuna Feb 16 '16 at 11:20
  • Yes, but the expression becomes too complex, i think there should be more straightforward way. – Suren Aznauryan Feb 16 '16 at 12:37
1

this should works fine:

ng-if="::dc.emailNotificationSchedule.progressInterval == dc.SkillCompletionProgressIntervals.NEVER_LOGGED_IN"

You don't need double colon twice

Przemek
  • 803
  • 4
  • 15