Skip to content

Instantly share code, notes, and snippets.

@Kirbaba
Created August 31, 2016 06:21
Show Gist options
  • Save Kirbaba/1b71c2e213bd2d079c184b044c437159 to your computer and use it in GitHub Desktop.
Save Kirbaba/1b71c2e213bd2d079c184b044c437159 to your computer and use it in GitHub Desktop.
uib-modal returning value on backdrop click
function setMinPrice() {
var modalInstance = $uibModal.open({
controller: 'setMinPriceCtrl',
templateUrl: templatePath + "room/filter.start_price.html",
animation: true,
backdrop: true,
size: "lg",
resolve: {
start_val: function() {
return $scope.priceVal;
}
}
});
/!**
* Получение значения поля модального окна и установка новых параметров для шакалы цены
*!/
$scope.$on("modalClosing", function (event, value) {
$scope.priceVal = value;
$scope.modalOpening = ($scope.priceVal * 2 - $scope.priceVal / 10);
$scope.upperBound = ($scope.priceVal * 2 - $scope.priceVal / 10);
$scope.start_max = $scope.priceVal * 2;
});
modalInstance.result.then(function (new_price) {
console.log("true");
}, function (new_price) {
console.log(new_price);
})
}
.controller('setMinPriceCtrl', function($scope, $uibModalInstance, $rootScope, start_val) {
$scope.starVal = start_val;
/!**
* Сохранение значения поля при закрытии модального окна
*!/
$scope.$on("modal.closing",function(){
$rootScope.$broadcast("modalClosing", $scope.modal_priceVal);
});
/!*$uibModalInstance.close(new_price);*!/
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment