JS Code,
var mod= $modal.open({
animation: true,
templateUrl: $scope.url,
controller: function($scope, $modalInstance,custObj) {
alert(custObj); /*************Line 1**************************/
$scope.save = function() {
$modalInstance.close();
};
$scope.cancel = function(){
$modalInstance.dismiss('cancel');
};
},
resolve : {
/************Resolving current scope value to retrieve it in Line 1*******/
custObj: $scope.customer;
}
});
虽然我通过$scope.customer
属性发送了resolve
对象,但模态控制器没有获取值。我错过了什么吗?
答案 0 :(得分:1)
custObj
- 对象中resolve
的值应该是一个返回你要注入的函数的函数:
resolve: {
custObj: function(){
return $scope.customer;
}
}
检查documentation $ routeProvider resolve
答案 1 :(得分:0)
使用
locals : {
custObj: $scope.customer;
}
而不是解决。