Angular2: two-way binding to map objects

How can I use two-way binding to map objects?

The following code does not work properly:

component:

@Component({ moduleId: module.id, selector: "my-component", templateUrl: "my-component.html", styleUrls: ["my-component.scss"], }) export class MyComponent { myMap: Map<string, Object> = Map<string, Object>() .set('first', {text: 'abc'}) .set('second', {text: 'foo'}) ; } 

Template:

 <div class="items" *ngFor="let item of myMap.values()"> <input type="text" [(ngModel)]="item.text" /> </div> 
+5
source share

All Articles