I'm reading angular docs.It just spawned a doubt in my mind about the following sentence REF
"evaluation of a template expression should have no visible side effects..."
If i understood correctly, it's because a "single detection cycle" executes the "templete expression": if that template expressions alters an info on which the rendered view depends, it won't show the change within that detection cycle...
My doubt is: for the same reason, is it safe to say that
a component with input a setter must not allow the setter to have visible side effects
Example
Can the following result in: the "list" does not render correctly when passing an input to the component
interface MyType{
description: string
}
@Component({
selector: 'my-cmp',
template: `
<div *ngFor="let item of _list">{{item.description}}</div>
`
}),
export class MyComponentList{
_list: MyType[];
@Input() set list( items: MyType[] ){
if(isListValid){
this._list = items;
}
this._list = [];
}
isListValid( aList: MyType[] ): boolean{
// logic
}
}