It is not that I don't want to update the view , I just don't understand why it does update it when I expect it not to ( since object is updated outside NG).
OK.
I have this simple code:
@Component({
selector: 'my-app',
template: `
<div>
<input type='button' value="Fill more" (click)="fillMore()"/>
<ul>
<li *ngFor="let item of Items ">
{{item}}
</li>
</ul>
</div>
`,
})
export class App {
Items:Array<number> = new Array<number>();
constructor(private mySignalRService:MySignalRService)
{
this.Items.push(...[1,2,3]); //initial values
}
fillMore()
{
this.mySignalRService.go(this.Items);
}
}
As you can see I'm also injecting a service :
@Injectable()
export class MySignalRService
{
makeDummyDb:Promise<Array<number>>()
{
return new Promise( (v,x)=> {
setTimeout(function (){v([100,200,300]);},800);
})
}
go(arr : Array<number>) : number
{
this.makeDummyDb().then((newValues)=>arr.push(...newValues)) ;
return 5; //this method must return a number
}
}
Now - When I click on the button (the "Fill more" button) , I do see the appended items , But when I think of it , it wasn't suppose to update becuase I believe the makeDummyDb:Promise
is outside angular's zone ( I might be wrong here)
Question:
Wasn't array update occur outside angular's zone ? How can I simulate a real outside zone so that the code won't work? (for testing)