相关疑难解决方法(0)

为什么两个相等的对象在Angular 2中显示"不相等"

我从json文件上传数组.每1.5秒我检查文件是否有任何变化(目前我在一个文件上测试没有任何变化),但当我检查是否

    if ( this.itemsParentArray[i] !== this.itemInArray[i] )
Run Code Online (Sandbox Code Playgroud)

它始终显示它不相等,并且console.log(""不等于")

我错过了代码中的内容吗?这里是:

export class HomeComponent {
itemsParentArray = [];
itemInArray = [];
myRes: Content;
showAssigned:boolean = false;

constructor(private structureRequest: StructureRequestService) {
    setInterval(() => {
        this.timerGetStructure();
    }, 1500);
}
//  using with setInterval to get new data and sets into content Array with this.updateItems(result) if it's new

timerGetStructure() {
    this.structureRequest.sendRequest().subscribe((result) => this.updateItems(result));
}
updateItems(result) {
    this.myRes =  result;
    this.itemInArray = this.myRes.content;
    for ( let i = 0; i < this.itemInArray.length; i++) {
                if ( …
Run Code Online (Sandbox Code Playgroud)

angular

6
推荐指数
1
解决办法
9676
查看次数

标签 统计

angular ×1