【发布时间】:2015-12-04 17:27:45
【问题描述】:
我想在控制器端获取工厂返回值。现在我发现了错误'无法读取未定义的属性'then'。 我在保存函数中调用了工厂。'confirmmodal' 是工厂。我想获取触发 ok 函数时返回的 $scope.test 值
Controller
$scope.save = function(){
$rootScope.showspinner = true;
if(!$scope.message) $scope.message = "Sorry no request message found..";
// $scope.customer=confirmmodal.transientModal($scope.message);
//console.log($scope.customer);
confirmmodal.transientModal($scope.message).then(function(data){
$scope.value = data;
});
};
Factory
transientModal: function(text) {
$rootScope.transient_modal = true;
var modalInstance = $modal.open({
templateUrl: 'partials/transient-modal/confirm_modeltemplate.html',
controller: function($scope, $modalInstance) {
if(text) $scope.alertmsg = text; else $scope.alertmsg = "Sorry no request message found..";
$rootScope.showspinner = true;
$rootScope.showspinner = false;
$scope.ok = function() {
alert("ok button");
$scope.test = 'tesating';
return $scope.test;
//$modalInstance.dismiss('cancel');
};
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
}
});
}
【问题讨论】:
标签: angularjs controller