Simple scenario
Parent component has an array, which is passed to child component with @Input().
child component displays a ion-select wit array elements as options.
parent modifies the array, but select popup(alert) remains same
I would expect options should reflect values of new array. parent.ts
remainingBoards: number[];
boardNo: number = 0;
constructor() {
this.remainingBoards = new Array(10 - this.boardNo).fill(0).map((x, i) => i + 1 + this.boardNo);
this.boardNo = this.remainingBoards[0];
}
deleteFirst() {
this.remainingBoards = new Array(10 - this.boardNo).fill(0).map((x, i) => i + 1 + this.boardNo);
this.boardNo = this.remainingBoards[0];
}
Your component is not refreshing. If you did the equivalent of F5 on your component, you’d see the new array. If you want your Input() to update whenever new data is available, you need to use inside your input set/get and a Subject-type-thing. (I use BehaviorSubject.) Then your Input keeps listening, and presents new data to the component.
If you see the screenshot, the text elements (select header as well as popup header) has the new value of remainingboards. So component has the new value but select popup has a problem.
Selected value of the ion-select is also updated (by @input() boardNo).
as it happens, same code was working fine for me too in v3. have started porting to v4 and found this problem. I’m strongly of the opinion that its a bug, but wanted to give it a go here.
I can’t tell from a quick glance at the Stencil documentation whether reflectToAttr would achieve this or not, so I’ll take your word for it. In any event, all other ordinary Angular components propagate change detection automatically in situations like this, and I’m with @jhavinay that this one should as well.
I can’t see reflectToAttr on header or subheader, but they display the new value.
at a quick glance it seems the magic is being done by {} rater than reflect to attr, and options are already in curly braces.
Having said that, let me clarify, i have never worked (or even looked at) stencil code before. So i might be miles off.
Having exactly the same issue. The attribute updates when the page is reconstructed, but not when doing change detection (not even on manual change detection trigger).
I can confirm that this has worked fine in ionic v3 as well, so in my mind definitely a bug in v4.