我在AngularJS中使用uibModal框架如下:
vm.openTotalScore = () => {
$uibModal.open({
templateUrl: 'app/modules/scoreforms/cost/scoreform.html',
scope: $scope,
controller: 'CostScoreFormController',
controllerAs: 'vm',
backdrop: 'static',
resolve: {
rankingSettings: function() {
return vm.rankingdata;
},
score: function() {
return vm.risk.TotalScore;
},
costScoringData: function(ScoreFormService){
var fields = vm.risktitle.split(' ');
return ScoreFormService.getCostScoringData(vm.state.params.riskId, vm.impacttypename, fields[0]);
},
currencysymbol: function() {
return vm.currencysymbol;
}
}
}).opened.then(function(success){
});
}
当打开模态窗体时,我需要能够在模态窗体上触发图形元素的重新渲染。我正在使用DevExpress DevExtreme控件,并且在我刷新/调整页面大小之前,其中一个控件无法正确绘制。他们告诉我,一旦表格可见,我需要对他们的控制进行渲染。但是,我不确定如何从打开表单的控制器执行此操作。
我能想到的唯一方法就是以某种方式告诉控制器表单现在已打开,表单可以重新呈现。
另一种方法是让控制器自动知道表格现在可见,但我不知道该怎么做。
我将uibModalInstance传递给控制器,如下所示,我可以在那里处理已打开的承诺吗?
constructor($state, $scope, $translate, $stateParams, $filter, $uibModalInstance, logger, rankingSettings, score, costScoringData, currencysymbol) { //, score)
{
'ngInject';
var vm = this;
vm.logger = logger;
vm.state = $state;
vm.translate = $translate;
vm.logger = logger;
vm.submitted = false;
vm.modelInstance = $uibModalInstance;
vm.costScoringData = costScoringData;
vm.rankingSettings = rankingSettings;
vm.score = score;
vm.currencysymbol = currencysymbol;
vm.cancel = function () {
vm.modelInstance.close();
};
this.getOptions();
this.loadGridData();
this.showDevExtremeGrid();
}
答案 0 :(得分:1)
另一种方法是让控制器自动知道表格现在可见,但我不知道该怎么做。
尝试使用$ timeout
$timeout(function(){
//Your codes goes here
});