Skip to main content
deleted 2 characters in body
Source Link
tomups
  • 6.2k
  • 2
  • 25
  • 28

Have Object.keys accessible in the template and use it in *forEach*ngFor.

@Component({ selector: 'app-myview', template: `<div *ngFor="let key of objectKeys(items)">{{key + ' : ' + items[key]}}</div>` }) export class MyComponent { objectKeys= Object.keys; items = {keyOne: 'value 1', keyTwo: 'value 2', keyThree: 'value 3'}; constructor(){} } 
@Component({ selector: 'app-myview', template: `<div *ngFor="let key of objectKeys(items)">{{key + ' : ' + items[key]}}</div>` }) export class MyComponent { objectKeys = Object.keys; items = { keyOne: 'value 1', keyTwo: 'value 2', keyThree: 'value 3' }; constructor(){} } 

Have Object.keys accessible in the template and use it in *forEach.

@Component({ selector: 'app-myview', template: `<div *ngFor="let key of objectKeys(items)">{{key + ' : ' + items[key]}}</div>` }) export class MyComponent { objectKeys= Object.keys; items = {keyOne: 'value 1', keyTwo: 'value 2', keyThree: 'value 3'}; constructor(){} } 

Have Object.keys accessible in the template and use it in *ngFor.

@Component({ selector: 'app-myview', template: `<div *ngFor="let key of objectKeys(items)">{{key + ' : ' + items[key]}}</div>` }) export class MyComponent { objectKeys = Object.keys; items = { keyOne: 'value 1', keyTwo: 'value 2', keyThree: 'value 3' }; constructor(){} } 
deleted 1 character in body
Source Link
tomups
  • 6.2k
  • 2
  • 25
  • 28

Have Object.keys accessible in the template and use it in *forEach.

@Component({ selector: 'app-myview', template: `<div *ngFor="let key of keysGetterobjectKeys(items)">{{key + ' : ' + items[key]}}</div>` }) export class MyComponent {   keysGetter =objectKeys= Object.keys; items = {keyOne: 'value 1', keyTwo: 'value 2', keyThree: 'value 3'}; constructor(){} } 

Have Object.keys accessible in the template and use it in *forEach.

@Component({ selector: 'app-myview', template: `<div *ngFor="let key of keysGetter(items)">{{key + ' : ' + items[key]}}</div>` }) export class MyComponent {   keysGetter = Object.keys; items = {keyOne: 'value 1', keyTwo: 'value 2', keyThree: 'value 3'}; constructor(){} } 

Have Object.keys accessible in the template and use it in *forEach.

@Component({ selector: 'app-myview', template: `<div *ngFor="let key of objectKeys(items)">{{key + ' : ' + items[key]}}</div>` }) export class MyComponent { objectKeys= Object.keys; items = {keyOne: 'value 1', keyTwo: 'value 2', keyThree: 'value 3'}; constructor(){} } 
Better naming
Source Link
tomups
  • 6.2k
  • 2
  • 25
  • 28

Have Object.keys accessible in the template and use it in *forEach.

@Component({ selector: 'app-myview', template: `<div *ngFor="let ikey of keyGetterkeysGetter(items)">{{ikey + ' : ' + items[i]items[key]}}</div>` }) export class MyComponent { keyGetterkeysGetter = Object.keys; items = {keyOne: 'value 1', keyTwo: 'value 2', keyThree: 'value 3'}; constructor(){} } 

Have Object.keys accessible in the template and use it in *forEach.

@Component({ selector: 'app-myview', template: `<div *ngFor="let i of keyGetter(items)">{{i + ' : ' + items[i]}}</div>` }) export class MyComponent { keyGetter = Object.keys; items = {keyOne: 'value 1', keyTwo: 'value 2', keyThree: 'value 3'}; constructor(){} } 

Have Object.keys accessible in the template and use it in *forEach.

@Component({ selector: 'app-myview', template: `<div *ngFor="let key of keysGetter(items)">{{key + ' : ' + items[key]}}</div>` }) export class MyComponent { keysGetter = Object.keys; items = {keyOne: 'value 1', keyTwo: 'value 2', keyThree: 'value 3'}; constructor(){} } 
Source Link
tomups
  • 6.2k
  • 2
  • 25
  • 28
Loading