Is there any other way to display a dialog box dynamically

I took a model to display the content on click button(). I already created the code, and my modal works fine too. But I want it to appear as Alert in the upper corner of my window when I click on button(). I tried my best to do it. But, I hope, I could not continue further.

My pluker: https://plnkr.co/edit/MgGSEU4ZSsmF36mSLW8Y?p=preview

You can check it out here.

+4
source share
2 answers

If you're interested in a solution that looks more like AngularJS, take a look at the ngDialog service. This will allow you to embed dialogue features in any controller that he needs. In addition, its openConfirm method will return a promise that will be allowed or rejected depending on how the dialog was closed (perfect for your example, which looks like a confirmation / cancellation dialog).

app.controller('demo', ['$scope', 'ngDialog', function($scope, ngDialog) {
  $scope.openDialog = function() {
    ngDialog.openConfirm({
      templateUrl: 'dialog-template.html',
      scope: $scope
    }).then(function () {
      console.log('confirm');
    }).catch(function () {
      console.log('cancel');
    })
  }
}])

Here's the fork of your plunk using ngDialog to create a confirmation / cancellation dialog that is aligned at the top right of the screen.

Updated Plunk with ngDialog

ngDialog GitHub repository and instructions

0
source

Bootstrap Modal - JavaScript, . , -.

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2>Modal Example</h2>
  <!-- Trigger the modal with a button -->
  <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

  <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
    
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Modal Header</h4>
        </div>
        <div class="modal-body">
          <p>Some text in the modal.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
      
    </div>
  </div>
  
</div>

</body>
</html>
Hide result

: LINK

:

  • Bootstrap , .
  • . .
  • . : , .
  • .

, JQuery: LINK

0

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


All Articles