Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

angular conditional directives

//if 
<div *ngIf='[condition]'> </div>   
  //if [condition]==true the div will be shown

//for 
<div *ngFor='let [data] of [dataArray]; let i=index;'>
  <h2> {{i}} {{data.title}} </h2>
  <img src='{{data.image}}' />
  </div>   
  //the data contained in an array will be displayed element by element
  //similar to the function .map() in React

// 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

  
Comment

PREVIOUS NEXT
Code Example
Typescript :: reflect-metadata 
Typescript :: how to make dots react native 
Typescript :: hide elements using DOM in TypeScript 
Typescript :: prolog check if element in different lists are same 
Typescript :: apexcharts dataURI style 
Typescript :: directions api remove points bubble 
Typescript :: list of elements in watir 
Typescript :: how to make auto conversion of blogger texts with fonts installed in blog theme 
Typescript :: google fonts roboto 
Cpp :: how to downgrade numpy 
Cpp :: go read file to string 
Cpp :: c++ primality test 
Cpp :: flutter convert datetime in day of month 
Cpp :: c++ hello word 
Cpp :: jupyter lab use conda environment 
Cpp :: c++ milliseconds 
Cpp :: c++ text formatting 
Cpp :: c++ check if string contains substring 
Cpp :: c++ min 
Cpp :: C++ Kelvin to Celsius 
Cpp :: collections c# vs c++ 
Cpp :: C++ std::async wait is taking forever 
Cpp :: fast input and output c++ 
Cpp :: how to change certain number from set c++ 
Cpp :: c++ uniform_real_distribution get same result 
Cpp :: delete specific vector element c++ 
Cpp :: c++ find sum of vector 
Cpp :: convert string to number c++ 
Cpp :: c++ cli convert string to string^ 
Cpp :: initializing 2d vector 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =