Just dipping my toes into Angular2 and attempting to append a new item to the list through input. However, upon clicking submit, instead of text I get [object Object].
Check out the code snippet below:
app.component.html
<form (submit)="addItem(item)">
<md-input-container>
<input [(ngModel)]="name" mdInput placeholder="add" name="addNew">
</md-input-container>
<button type="submit" md-icon-button>
<i class="material-icons">send</i>
</button>
</form>
app.component.ts
items = Players;
name;
addItem(name): void {
this.items.push(new Player({
name : name
}));
}
player.ts
export class Player {
id: number;
name: string;
count: number;
constructor(name){
this.id;
this.name = name;
this.count = 0;
}
all-players.ts
export let Players: Player[] = [
];
Appreciate any help or suggestions provided!