Angular JS ternary operator inside div tag

Am using the div condition as shown below

<div data-index="5" class="col-xs-12 col-sm-4 col-md-3 col-lg-2 tiles ${ {{myvariable.data}} ? 'hidden-lg hidden-md hidden-xs hidden-sm':''}" data-myapp-detail="somexyz">

Where {{myvariable.data}}poses the problem when it becomes "false." is there any angular js condition that i can initiate a variable based on {{myvariable.data}}and use this variable in a three dimensional tag condition.

Where, as if I were saving the boolean false directly, and not {{myvariable.data}}, it works as expected.

<div data-index="5" class="col-xs-12 col-sm-4 col-md-3 col-lg-2 tiles ${ false ? 'hidden-lg hidden-md hidden-xs hidden-sm':''}" data-myapp-detail="somexyz">
+4
source share
1 answer

For angular2

<div data-index="5" 
  class="col-xs-12 col-sm-4 col-md-3 col-lg-2 tiles"
  [ngClass]="myvariable.data ? 'hidden-lg hidden-md hidden-xs hidden-sm':''" 
  data-myapp-detail="somexyz">

or

<div data-index="5" 
  class="col-xs-12 col-sm-4 col-md-3 col-lg-2 tiles"
  [ngClass]="myvariable.data ? ['hidden-lg', 'hidden-md', 'hidden-xs', 'hidden-sm']:''" 
  data-myapp-detail="somexyz">
+6
source

Source: https://habr.com/ru/post/1652814/


All Articles