Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

iterate object ngfor

// In your ts file
Object = Object;

// then in the template:

<div *ngFor="let key of Object.keys(objs)">
   my key: {{key}}
   my object {{objs[key] | json}} <!-- hier I could use ngFor again with Object.keys(objs[key]) -->
</div>
Comment

Iterate object using ngFor in angular

@Component({
  selector: 'keyvalue-pipe',
  template: `<span>
    <p>Object</p>
    <div *ngFor="let item of object | keyvalue">
      {{item.key}}:{{item.value}}
    </div>
    <p>Map</p>
    <div *ngFor="let item of map | keyvalue">
      {{item.key}}:{{item.value}}
    </div>
  </span>`
})
export class KeyValuePipeComponent {
  object: {[key: number]: string} = {2: 'foo', 1: 'bar'};
  map = new Map([[2, 'foo'], [1, 'bar']]);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: heroicons 
Javascript :: node downgrade windows 
Javascript :: on window resize react 
Javascript :: checkbox on click jquery select all 
Javascript :: check if parameter is array javascript 
Javascript :: how to convert whole strig in lowercase in js 
Javascript :: round till 2 digit in jquery 
Javascript :: automatically add typedef to module.exports vscode site:stackoverflow.com 
Javascript :: regex get only domain name from url 
Javascript :: JS get length of an object 
Javascript :: ejs comments 
Javascript :: vue npx 
Javascript :: javascript loop FormData 
Javascript :: jimp get image size 
Javascript :: how to add a right click listener javascript 
Javascript :: datepicker on change 
Javascript :: select a form by name jquery 
Javascript :: select all children javascript 
Javascript :: random password javascript 
Javascript :: cors in express 
Javascript :: how to find parent table of tr in jquery 
Javascript :: last query prisma 
Javascript :: how to check if file upload is empty jquery 
Javascript :: jquery disable enter key submit 
Javascript :: carousel speed bootstrap 
Javascript :: track window size js 
Javascript :: jquery avoid enter submit 
Javascript :: js delete duplicates from array 
Javascript :: javascript round float 
Javascript :: javascript sort array of objects ascending and descending order 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =