0
我的ES6控制器类如下。我无法执行代码的promise解析部分中的$ compile,$ location等Angular方法。它引发错误“Uncaught(in promise)TypeError:this。$ compile不是一个函数(...)”我正在使用箭头函数来获取promise中的这个访问。任何想法如何解决这个问题?
import DashboardService from './DashboardService';
class DashboardController
{
/*@ngInject*/
constructor($scope, DashboardService, $location, $compile, PLATFORM)
{
this.$scope = $scope;
this.DashboardService = DashboardService;
this.$location = $location;
this.$compile = $compile;
this.PLATFORM = PLATFORM;
}
UpdateGrid(clients)
{
this.PLATFORM.miraLoader.moduleImport('platform!kendo-ui').then((kendo) => {
var dataSource = new kendo.data.DataSource({ data: clients, pageSize: 10 });
angular.element("#GridTest").kendoGrid({
height: 415,
scrollable: true,
dataBound: function(){this.$compile(angular.element("#GridTest"))(this.$scope);}
});
var grid = angular.element("#GridTest").data("kendoGrid");
grid.setDataSource(dataSource);
grid.dataSource.read();
this.$compile(angular.element("#GridTest"))(this.$scope);
});
}
GoToClient(id){ this.$location.path('/Client/'+id); }
AdvisorChange() {
this.DashboardService.ClientsGet(this.wiquid, this.advisorid).then((clients) => {
this.UpdateGrid(clients.data.d);
});
}
}
export default DashboardController;
谢谢邓肯..现在工作正常... –