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

angular how to iterate object

keys() : Array<string> {
    return Object.keys(this.myDict);
  }
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript two decimal places after division 
Javascript :: ts node cannot use import statement outside a module 
Javascript :: javascript check for null variables 
Javascript :: can promise is going to be handle asynchronously 
Javascript :: nodejs for windows 7 
Javascript :: format date javascript 
Javascript :: moment get day 
Javascript :: how to get output of console.log in a file in javascript 
Javascript :: number to array js 
Javascript :: javascript auto scroll a page to top 
Javascript :: javascript set input value by id 
Javascript :: axios middleware 
Javascript :: react render component after fetch 
Javascript :: file name in react input 
Javascript :: focus element javascript 
Javascript :: validationResult is not defined 
Javascript :: checkbox default value and checked value get in jquery 
Javascript :: js stairs algorithm 
Javascript :: usereducer example 
Javascript :: vuejs get value of checkbox group 
Javascript :: cart page url in shopify 
Javascript :: react webpack config example 
Javascript :: Difference in push and navigate in react Navigation 
Javascript :: javascript sum of arguments 
Javascript :: react navigation history clear 
Javascript :: get odd elements of list javascript 
Javascript :: usecallback vs usememo 
Javascript :: js string methods 
Javascript :: regex all 
Javascript :: mongoBD $inc operator 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =