0
我有我的角度服务和控制器,我需要通过服务之间的数据控制器为voucher_code获得价值通行证服务之间的角度数据到控制器
角服务:
myApp.service('tradeData', function ($http) {
var service ={};
var voucher_code;
service.postTrade = function(trade){
console.log(trade)
console.log("TEST")
var promise = $http.post('tradein', trade);
promise.
then(function successCallback(response) {
angular.extend(trade, response.tradeData);
//console.log("======="+response.data)
voucher_code = JSON.stringify(response.data.voucher_code, null, 4); // (Optional) beautiful indented output.
console.log("test123",voucher_code);
return voucher_code;
}, function errorCallback(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
return promise;
};
return service;
})
角控制器:
myApp.controller('ModalInstanceCtrl', function($scope, $uibModalInstance, items, PersonalInfoService, tradeData) {
$scope.cancel = function() {
$uibModalInstance.dismiss('cancel');
}
$scope.personal = PersonalInfoService;
$scope.printToCart = function(printSectionId) {
var innerContents = document.getElementById(printSectionId).innerHTML;
var popupWinindow = window.open('', '_blank', 'width=550,height=700,scrollbars=no,menubar=no,toolbar=no,location=no,status=no,titlebar=no');
popupWinindow.document.open();
popupWinindow.document.write('<html><head><link rel="stylesheet" type="text/css" href="css/print.css" media="screen, print" /></head><body onload="window.print()">' + innerContents + '</html>');
popupWinindow.document.close();
}
$scope.Product = tradeData;
console.log("sfsdff" , tradeData.voucher_code);
// console.log("santo", voucher_code);
// console.log("santo", service);
})
任何想法通过从服务voucher_code的值到控制器