0

I have defined an expression in ng-init which is being evaluated to false but when I assign it to a variable, its being evaluated to true.

 <div class="small-6 medium-6 large-6 cell" ng-init="disablePMPR = !((roleControl.disableBlock) && (roleControl.block == 1) && (roleControl.userRole == 'PMPR'))">

This expression is evaluated to false, which is correct ==>

   !((roleControl.disableBlock) && (roleControl.block == 1) && (roleControl.userRole == 'PMPR'))

But disablePMPR is evaluated to true. Is there other way to define this expression ?

Arjan Einbu
  • 13,543
  • 2
  • 56
  • 59
Shaam
  • 92
  • 13
  • It is hard to tell without knowing what all of those values do. Have you tried removing the `!` Logical Not? – Michael Hancock Oct 04 '17 at 07:04
  • Did you check disablePMPR inside the roleControlor or in the scope? – Tonino Oct 04 '17 at 07:06
  • if `((roleControl.disableBlock) && (roleControl.block == 1) && (roleControl.userRole == 'PMPR'))` evalutes to false than `!((roleControl.disableBlock) && (roleControl.block == 1) && (roleControl.userRole == 'PMPR'))` will be true. what is wrong in this. – Ved Oct 04 '17 at 07:09
  • The expression is being evaluated to **true** and I have put the _!_ to make it false. The variable **disablePMPR** is having value TRUE – Shaam Oct 04 '17 at 07:09
  • Please, don't use ng-init. It is a bad practice. Just move it to the controller. – NechiK Oct 04 '17 at 07:47
  • You mean,!((roleControl.disableBlock) && (roleControl.block == 1) && (roleControl.userRole == 'PMPR')) evaluated to false , but disablePMPR is getting true value. – Himanshu Shekhar Oct 04 '17 at 07:51
  • @HimahshuShekhar yes exactly – Shaam Oct 04 '17 at 09:13

0 Answers0