I have an array passed from the background
the data in the array is constantly changing
I want to refresh automatically when the contents of the array change without reorganizing the page template block
how can this be achieved?
I have an array passed from the background
the data in the array is constantly changing
I want to refresh automatically when the contents of the array change without reorganizing the page template block
how can this be achieved?
array is a reference variable, and if no impure pipe,angular is added to it, it will only detect whether the address of the variable has changed each time it is detected. That is to say, even if the content changes, but the memory address of the variable does not change, angular will not think that the variable has changed, so the page will not be refreshed. You can use async pipe. Or set the array variable to null, and then reassign it each time the array content is updated. But the second method is not very rigorous and should be used with caution.
Asynchronous operation may not trigger the check mechanism of angular. At this point, you can try to manually remind angular to re-render the view
import { NgZone } from '@angular/core';
constructor(public _ngZone:NgZone) {}
public refresh() {
this._ngZone.run(() => {});
}
Previous: How to set the FontSmoothing? of CSS by canvas
Next: The problem of el-table adaptive container height in element-ui
recently, the project has been developing with angular6, encapsulating an interceptor for HttpInterceptor, but has been reporting errors. < H2 > Code in auth.service.ts < H2 > import {Injectable} from @angular core ; import {HttpService} from . ...
as the title: novice to angular, I really don t understand the official method of obtaining routing parameters. The code is as follows -sharp store assets-list case * : store assets-list caseid :assets-listngOnInit * ques...
encountered a problem with angular development. The framework tinyUi used by provides a spinner component that needs to be initialized with a set of parameters. Html may look like this <cti-spinner ng-repeat="item in list" id="option...
has been executed to the yellow part, res [ data ] .itemMaterialType = 3, this.itemMaterialType= res [ data ] .itemMaterialType; this sentence has been executed, why this.itemMaterialType has always been the theoretical this.itemMaterialType=3 ...
use angular1.x to pass multiple parameters, and the target page only receives the first ...
@ Input @ Output must be bound in the template like this < app-test > so if I use router to control the page today, only < router-outlet > < router-outlet > there is no < app-test > this template what should I do at this time? ...
I have been worried about this, and I have checked a lot of information on the Internet, and I still have no ideas. I have less contact with this piece and a lot of people don t understand it. Can you tell me about the solution, or recommend several rel...
there is an array like this [ { id:1, info: {name:"abc"} show: true }, { id:2, info: {name:"abc"} show: true }, { id:3, info: {name:"qq"} show: true } ] then I want...
suppose there is an array like this [ {eid: 1, name: aa}, {eid: 1, name: bb}, {eid: 2, name: cc}, {eid: 1, name: dd}, {eid: 3, name: ee}, {eid: 1, name: ff}, {eid: 2, name: gg} ] if I want him to run ngFor can this arr...
export class AuthGuard implements CanActivate { constructor(private PassportService: PassportService, private CookieService: CookieService, private router: Router) { } canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {...
code looks like this, https: stackblitz.com edit a... what I want to do is to click and find all those with id, then turn their isOpen into true, and then switch with id . is there a way to do this? ts cards = [{name: div1 ,id: 1,isOpen: fals...
test = [ ["qwe","1"], ["ewq","2"], ["www","4"] ["aaa","3"], ] an array of segments as above I want to rank according to the n...
I want to add a section of reusability of code. Code looks like this. <ng-container *ngIf="foo === 1 ;else qq1">< ng-container> <ng-container *ngIf="foo === 2 ;else qq2">< ng-container> <ng-template...
html: <ng-container *ngIf="oCode_test1(table.oCode) "> <span>{{aaa}}:< span> < ng-container> <ng-container *ngIf="oCode_test2(table.oCode) "> <span>{{bbb}}:< span> < ng-containe...