Ionic 2 use, I need ngmodel to have a value of a class variable, but the error when placing in the view, follows my code: viiew
<ion-navbar *navbar>
<ion-title>
POSimplex
</ion-title>
</ion-navbar>
<ion-content class="home" padding>
<button ion-button full (click) = "teste()">Login</button>
<p>
<button ion-button full (click) = "addInput()">Criar conta</button>
</p>
<ion-list>
<ion-item *ngFor="let item of inputs">
<ion-label fixed>{{item.title}}</ion-label>
<ion-input type="{{item.type}}" value="{{item.value}}" [(ngModel)] = "{{item.model}}"></ion-input>
</ion-item>
</ion-list>
</ion-content>
ts:
import {Component} from "@angular/core";
import {NavController, Alert} from 'ionic-angular';
@Component({
templateUrl: 'build/pages/home/home.html'
})
export class HomePage {
inputs: Array<{title: string, type: string, value: any, model: string}>;
inputsList: Array<Array<{title: string}>>;
sl:string
constructor(private navController: NavController) {
this.inputsList = [];
this.inputs = [
{title: 'User Name', type: 'text', value: 'Fulano de tal', model: 'sl'},
{title: 'Price', type: 'text', value: 500, model: 'sl'}
];
}
addInput() {
//this.inputs.push({ title: "teste", type: "text", value: "valor" });
}
teste() {
let alert = Alert.create({
title:'teste',
message:'msg'+this.sl
});
this.navController.present(alert)
}
}
Console error: browser_adapter.js: 77EXCEPTION: Error: Uncaught (in promise): Template parse errors: Parser Error: Got interpolation ({{}}) where expression was expected at column 0 in [{{item.model}}] in HomePage @ 17: 67 ("fixed & {{item.title}} ] [(ngModel)]="{{item.model}}" > "): HomePage @ 5: 67 Parser Error: Got interpolation ({{}}) where expression was expected at column 0 in [{{item.model}} = $ event] in HomePage @ 17: 67 ("fixed > {{item.title}} ] [(ngModel)]="{{item.model}}" > "): HomePage @ 17: 67
How can I resolve?