如何将解析异步数据注入 ui bootstrap 模态 angular?
How can I inject with resolve async data to a ui bootstrap modal in angular?
如何将解析异步数据注入 angular 中的 ui bootstrap 模态?
下面的代码是打开modal的controller。
import insertOpportunityModal from './insertOpportunityModal.html';
export default class OpportunitiesCtrl {
constructor($uibModal, OpportunitiesService, EngagementsService, PAGE_SIZE) {
this.$uibModal = $uibModal;
this.OpportunitiesService = OpportunitiesService;
this.EngagementsService = EngagementsService;
}
openInsertModal() {
var modalInstance = this.$uibModal.open({
animation: false,
size: 'md', //['lg', 'md', 'sm']
template: insertOpportunityModal,
controller: 'InsertOpportunityModalCtrl',
controllerAs: 'vm',
resolve: {
opportunityTypes: function (EngagementsService) {
return EngagementsService.all();
}
}
});
modalInstance.rendered.then(() => {
});
modalInstance.result.then(() => {
console.log('modal closed');
}, (error) => {
console.log(error);
});
}
}
OpportunitiesCtrl.$inject = ['$uibModal', 'OpportunitiesService', 'EngagementsService', 'PAGE_SIZE'];
opportunityTypes 在模态控制器中未定义。
它适用于同步数据,但不适用于承诺。
怎么解决?
export default class InsertOpportunityModalCtrl {
constructor($uibModalInstance, OpportunitiesService, opportunityTypes) {
this.$uibModalInstance = $uibModalInstance;
this.OpportunitiesService = OpportunitiesService;
this.opportunityTypes = opportunityTypes;
console.log('opportunityTypes', opportunityTypes);
}
save() {
}
cancel() {
this.$uibModalInstance.dismiss('cancel');
}
}
InsertOpportunityModalCtrl.$inject = ['$uibModalInstance', 'OpportunitiesService'];
你必须在 InsertOpportunityModalCtrl
中注入 opportunityTypes
到。
InsertOpportunityModalCtrl.$inject =
['$uibModalInstance', 'OpportunitiesService', 'opportunityTypes'];
如何将解析异步数据注入 angular 中的 ui bootstrap 模态? 下面的代码是打开modal的controller。
import insertOpportunityModal from './insertOpportunityModal.html';
export default class OpportunitiesCtrl {
constructor($uibModal, OpportunitiesService, EngagementsService, PAGE_SIZE) {
this.$uibModal = $uibModal;
this.OpportunitiesService = OpportunitiesService;
this.EngagementsService = EngagementsService;
}
openInsertModal() {
var modalInstance = this.$uibModal.open({
animation: false,
size: 'md', //['lg', 'md', 'sm']
template: insertOpportunityModal,
controller: 'InsertOpportunityModalCtrl',
controllerAs: 'vm',
resolve: {
opportunityTypes: function (EngagementsService) {
return EngagementsService.all();
}
}
});
modalInstance.rendered.then(() => {
});
modalInstance.result.then(() => {
console.log('modal closed');
}, (error) => {
console.log(error);
});
}
}
OpportunitiesCtrl.$inject = ['$uibModal', 'OpportunitiesService', 'EngagementsService', 'PAGE_SIZE'];
opportunityTypes 在模态控制器中未定义。 它适用于同步数据,但不适用于承诺。 怎么解决?
export default class InsertOpportunityModalCtrl {
constructor($uibModalInstance, OpportunitiesService, opportunityTypes) {
this.$uibModalInstance = $uibModalInstance;
this.OpportunitiesService = OpportunitiesService;
this.opportunityTypes = opportunityTypes;
console.log('opportunityTypes', opportunityTypes);
}
save() {
}
cancel() {
this.$uibModalInstance.dismiss('cancel');
}
}
InsertOpportunityModalCtrl.$inject = ['$uibModalInstance', 'OpportunitiesService'];
你必须在 InsertOpportunityModalCtrl
中注入 opportunityTypes
到。
InsertOpportunityModalCtrl.$inject =
['$uibModalInstance', 'OpportunitiesService', 'opportunityTypes'];