我想将数据传递给模态,而不传递所有 $scope。我的模态在组件中。
angular.module('app').component('testModal', {
templateUrl: '/test-modal',
bindings: {
close: '&',
dismiss: '&',
resolve: '<'
},
controller: function ($scope, test) {
var vm = this;
this.test = test;
this.save = () => {
this.close()
}
this.cancel = function () {
this.dismiss()
}
}
})
我尝试传递如下数据(来自另一个控制器)
function openModal() {
testService.getTest().then(function(data) {
var modalInstance = $uibModal.open({
component: 'testModal',
size: 'lg',
resolve: {
test: function () {
return data;
}
}
})
})
}
但我有错误:angular.js:15567 Error: [$injector:unpr] Unknown provider: testProvider <- test <- catchError
我该如何处理?为什么在我的模态组件中没有读取“测试”?