[英]Unable to send data from factory into angularJs modal
This is a follow-up question to Angular-ui modal, sending data into modal controller from $http 这是Angular-ui模态的后续问题,将数据从$ http发送到模态控制器
I have the following code where I want to get data via a factory
to the modal. 我有以下代码,我想通过factory
将数据获取到模态。
$scope.docSetup = function() {
var modalInstance = $modal.open({
templateUrl : '/templates/dialog/docSetup.html',
controller : 'docSetupDlgCtrl',
resolve : {
dlgData : function(){
return TagService.list($scope.publication.id);
}
}
});
modalInstance.result.then(function (dlgData) {
$log.debug(dlgData);
}, function () {
$log.debug('Modal dismissed at: ' + new Date());
});
};
And here is the factory: 这是工厂:
app.factory("TagService", function($http, $log){
return {
list: function(selectedDoc){
$log.info("Tag service at work => list");
var httpPromise = $http.post("tags/list", { publicationId: selectedDoc });
httpPromise.then(function (response) {
$log.log(response.data);
return response.data;
}, function (error) {
$log.error(error);
});
}
}
});
The above isn't resolving any data into dlgData
. 上面没有将任何数据解析为dlgData
。 The factory is producing data and if I hardcode the data object into the 'resolve' function, it passes it. 工厂正在生产数据,如果我将数据对象硬编码为“解析”功能,它将通过它。
return
the entire httpPromise
as well: return
整个httpPromise
:
return httpPromise.then(function (response) {
$log.log(response.data);
return response.data;
}, function (error) {
$log.error(error);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.