Iterate over object in Angular

前端 未结 17 1338
攒了一身酷
攒了一身酷 2020-11-22 12:19

I am trying to do some things in Angular 2 Alpha 28, and am having an issue with dictionaries and NgFor.

I have an interface in TypeScript looking like this:

17条回答
  •  感情败类
    2020-11-22 12:59

    //Get solution for ng-repeat    
    //Add variable and assign with Object.key
    
        export class TestComponent implements OnInit{
          objectKeys = Object.keys;
          obj: object = {
            "test": "value"
            "test1": "value1"
            }
        }
        //HTML
          
    {{key}}
    {{obj[key]}}

提交回复
热议问题