How to find out if a modal is open in Angular UT Bootstrap

I am using Angular UT Bootstrap. If modally open, I would like to display true. If it does not open, I would like to display false. Is there any way to do this in HTML?

I tried using the following code, but this is wrong:

<code>myForm.$modalStack.opened={{myForm.$modalStack.opened}}</code>

Any thoughts on how to do this correctly?

Below is the relevant code that I use to run the modality:

HTML:

<button ng-click="myForm.agreement()">

Code in the controller:

.controller('MyFormCtrl',
  function ($location, $stateParams, $modal, $scope, $http) {
    var myForm = this;
    // . . . 

   myForm.agreement = agreement;

   function agreement() {

       $modal.open({

          templateUrl: 'views/agreement.html'
  })
});
+4
source share
1 answer

The property openedreturned $modal.openis a promise you can make.

So, using their example, see here - http://plnkr.co/edit/PsEqTIy8CDUU88HMLxbC?p=preview

$scope.modalOpen = false;
$scope.open = function (size) {
    var modalInstance =  $modal.open({
        animation: $scope.animationsEnabled,
        templateUrl: 'myModalContent.html',
        controller: 'ModalInstanceCtrl',
        size: size,
        resolve: {
            items: function () {
                return $scope.items;
            }
        }
    });

    modalInstance.opened.then(function () {
        $scope.modalOpen = true;
    });

    // we want to update state whether the modal closed or was dismissed,
    // so use finally to handle both resolved and rejected promises.
    modalInstance.result.finally(function (selectedItem) {
        $scope.modalOpen = false;
    });
};

promises, , . .opened - , , .result - , . , , $scope.modalOpen .

+10

Source: https://habr.com/ru/post/1599373/


All Articles