Good night, I'm doing a page in my ionic app and I want that, when I select an ion-select option, the page loads a form, I'm using ngif but I can not follow the code:
(ts)
todos: Observable<any>;
tipo: any = [
{tipos: 'Debito'},
{tipos: 'Credito'}
];
selectedTipo: any[] = this.tipo[1];
change = false;
secondChange = false;
constructor(public navCtrl: NavController, public navParams: NavParams, public todoService: TodoService, public alertCtrl: AlertController, public toastCtrl: ToastController) {
this.loadTodos();
}
pageSelect(tipoTipos, tipoValue){
console.log(tipoTipos);
this.selectedTipo = tipoTipos;
}
debitOn(){
console.log('Teste1')
}
creditOn(){
console.log('teste2')
}
(html)
<ion-content padding>
<ion-item>
<ion-label>Tipo de transação</ion-label>
<ion-select name="selectedTipo" ngModel (ngModelChange)="pageSelect($event, tipo.tipos, tipo.value)">
<ion-option value="" disabled>Escolha o tipo</ion-option>
<ion-option *ngFor="let t of tipo" [value]="tipo.tipos">
{{t.tipos}}
</ion-option>
</ion-select>
</ion-item>
<!-- form de debitos -->
<div *ngIf="change; then debitOn"></div>
<!-- <ng-template #debitOn></ng-template> -->
<!-- form de creditos -->
<div *ngIf="secondChange; then creditOn"></div>
<!-- <ng-template #creditOn></ng-template> -->
</ion-content>