【发布时间】:2016-07-08 09:42:29
【问题描述】:
在我的 Angular 应用程序(使用 ES6)中,我需要在使用以下代码从其他指令触发一些自定义事件后进行 ajax 调用:
class GridController {
constructor($scope, $rootScope, MyService) {
this.$scope = $scope;
this.$rootScope = $rootScope;
this.MyService = MyService
this.MyService.getItems(arg1, arg2).then((resp) => {
this.viewModel= resp;
});
this.$rootScope.$on('myEvent', (e, args) => {
this.MyService.getItems(arg1, args[1]).then((resp) => {
this.viewModel= resp;
});
}
});
}
问题是 成功 ajax 调用后视图没有更新。 有什么想法为什么会发生这种情况?
【问题讨论】:
-
this.MyService.getItems(arg1, args[1])- 没有 arg1。错字? -
我已经删除了代码,这些参数来自当前指令的绑定属性
标签: javascript angularjs ajax ecmascript-6