ng1,上代码:
//controller
this.PouchService.getSingleDoc(this.id)
.then(res => {
this.result = res;
console.log(this.result); //这里能输出正确的数据
});
//html,用了controller as
{{home.result}}
通过上边代码获取数据并绑定到页面上,数据在controller中已经更新了,但是页面没更新,不知道为什么。以前也总这么写,没有问题,难道是因为es6的事么?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
这点代码看不出啥毛病啊,你这es6也只是多了this的绑定的箭头函数。
疑点:
1、你这个
this.PouchService不在ctrl中,而是某个子函数的作用域内2、页面有其他报错?其他原因阻塞了apply
只有调用NG封装的XHR事件才会轮询$switch,自己更新数据要更新到视图上就需要手动
$scope.$digest或者$apply