Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

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
Typescript :: regex replace certain string 
Typescript :: go build could not read username 
Typescript :: git remove commits from branch after push 
Typescript :: check return type jest 
Typescript :: reduce an array of objects to string 
Typescript :: reading multiple objects from file in java 
Typescript :: mat dialog disable close 
Typescript :: typescript declare dictionary type 
Typescript :: formgroup reset values 
Typescript :: react link state 
Typescript :: Cannot choose between the following variants of project :react-native-camera: 
Typescript :: instragram basic api Display 
Typescript :: typescript recursive partial 
Typescript :: merge enum typescript 
Typescript :: nested array typescript 
Typescript :: angular send mailto html 
Typescript :: Extract and Exclude type TypeScript 
Typescript :: vue object array type props 
Typescript :: how are uv rays produced 
Typescript :: highlight styled components on vscode 
Typescript :: what are data points 
Typescript :: remove duplicate objects based on id from array angular 8 
Typescript :: Simple Bulk insert TSQL csv 
Typescript :: typescript array of mixed types 
Typescript :: Make Object properties Readonly TypeScript 
Typescript :: downloading youtube playlists using youtube-dl in highest quality 
Typescript :: remove item from array if exists in another array 
Typescript :: angular rxjs mergemap 
Typescript :: ganache web3 
Typescript :: typescript how to create an array instance 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =