Angular 2 - Dynamic Variables in ngModel

前端 未结 5 2054
半阙折子戏
半阙折子戏 2020-12-31 06:58

How to use dynamic variables in ngModel?

I am trying to use the code below but the following error appears:

5条回答
  •  死守一世寂寞
    2020-12-31 07:36

    Define array in component and keep pushing in it.

    export class AppComponent {
        qtd:any[] = {};
    }
    

    Then, update your template like

    {{ qtd | json}}

    In this all your dynamic models will be in qtd array

    Plunker

    Hope that helps!

提交回复
热议问题