Pass data from modal to another page in angularjs -
i need pass data modal page. please me accomplish task?
$scope.productdetails = function (size,selectedproduct) { var modalinstance = $uibmodal.open({ templateurl: 'productdetails.html', controller: function ($scope, $uibmodalinstance, product) { $scope.product = product; $scope.buynow = function (path) { $uibmodalinstance.close($scope.product); $location.path(path); // need pass $scope.product new page }; $scope.cancel = function () { $uibmodalinstance.dismiss('cancel'); }; }, size: size, resolve: { product: function () { return selectedproduct; } } });
be sure read docs on $uibmodal
: https://github.com/angular-ui/bootstrap/tree/master/src/modal/docs
the open()
method return object useful stuff in it. you're not doing object, that's magic is.
to pass data controller opened modal, use modalinstance.result
promise this:
modalinstance.result.then(function(data) { /*... data*/ });
once set up, can use $close()
function modal library places on scope resolve result
promise.
var data = {info: 'information returned parent controller'}; $scope.$close(data);
Comments
Post a Comment