I am trying to write a data record with Angular 2 and Typescript, but I had a problem updating the model. As I understand it, only primitive types can be attached to ng-model . But in my model, I have objects that I want to update. Is there any Angular specific way to do this instead of loading a hole object with a modified property that binds to ng-model ?
This is the model:
export class Project {
public id: number;
private title: string;
private region: Region;
}
This is the Angular Component class:
@Component({...})
export class ProjectForm {
public project: Project;
public regions: Array<Region>;
}
This is a view of ProjectForm:
...
<select id="region" [(ng-model)]="project.region.id">
<option *ng-for="#region of regions" [value]="region.id">
{{ region.name }}
</option>
</select>
source
share