Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

conditional inline style angular

// ngStyle (conditional Style)
<div *ngFor='let [data] of [dataArray]; let i=index;'>
  <h2 [style.background]="i>1? 'green': 'red'"> {{i}} {{data.title}} </h2>

  </div> 

//if the index of the element is 1 or 0, the background will be red, if it is over 1 the background will be green
Source by www.aanchalgarg.com #
 
PREVIOUS NEXT
Tagged: #conditional #inline #style #angular
ADD COMMENT
Topic
Name
2+8 =