Its possible to make action after ngIf?


#1

Hi, i have an ngIf Nested in two ngFor’s, to make a ion-list, but i dont want duplocated ion-list, is there a way to make that if the ngIf is correct then it changes a variable value like Show=false, so it doesnt keep making ion-lists? thanks

the element with *** is the one is giving me problems. My objective is to get the item-list created and filled with ion-items, but just once, i was getting them duplicated and i figured i could make a flag with hall.show, I’m getting the console.log and i know the show attribute is changing to false.

Html file

listaReady *** {{hall.name}} {{articulo.name}} {{setToFalse(hall)}} .ts File

import { Component,OnInit } from ‘@angular/core’;
import {IonicPage, NavController, NavParams} from ‘ionic-angular’;
import pasillo from ‘…/…/Data/pasillos’;
import { Pasillo } from ‘…/…/Data/pasillo.interface’;

@IonicPage()
@Component({
selector: ‘page-lista-ready’,
templateUrl: ‘lista-ready.html’,
})
export class ListaReadyPage implements OnInit{

listaRdy:{name:string,pasillo:number,id:string}[];
pasillosObj:{name:string,value:number,show:boolean}[];

constructor(public navCtrl: NavController, public navParams: NavParams) {

this.listaRdy=this.navParams.data;

}
ngOnInit(){
this.pasillosObj=pasillo;
}

setToFalse(variable:Pasillo){
const position = this.pasillosObj.findIndex((variableEl:Pasillo)=>{
return variableEl.value == variable.value
});
this.pasillosObj[position].show=false;
console.log(position);
console.log(this.pasillosObj[position].show);
console.log(variable);
console.log(this.pasillosObj);
}
}


#2

Please post code. What you are describing sounds like you are trying to do control structures in templates, which is not very idiomatic. There should be a cleaner way of achieving your goal.