0

I want to create a pop up on click through angular, The problem is if I use the modal popup, when click outside of the popup it disappers automatically. So I want to pass a div onclick in the same page, can anyone tell me how to use it angular. Thanks in advance!

3
  • Some code? Fiddle? Something you have tried / researched? Commented Jul 10, 2015 at 9:04
  • what do you mean "popup"? is that alert kind of or customized HTML popup? Commented Jul 10, 2015 at 9:09
  • customized html popup and here is my code Commented Jul 10, 2015 at 9:49

2 Answers 2

1

If you dont want disappers automatically when click outsite of the popup. You can set backdrop to static when popup opened.

$modal.open({backdrop:'static'})

Sign up to request clarification or add additional context in comments.

2 Comments

This is my code and I want popup my coustomized html without closing automatically
why dont you use the modal of angular-bootstrap angular-ui.github.io/bootstrap/#/modal
0
 <section class="content">
      <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <h3 class="box-title">Visitors List</h3>
              <div class="box-tools">
                <div class="input-group">

                  <input type="text" name="table_search"  
         ng- model="query" class="form-control input-sm pull-right" 
        style="width: 150px;" placeholder="Search"/>
                  <div class="input-group-btn">
                    <button class="btn btn-sm btn-default">
            <i class="fa fa-search"></i></button>
                  </div>
                </div>
              </div>
            </div>
            <div class="box-body table-responsive no-padding">
   <div ng-controller="MainCtrl" class="container">
    <table class="table table-hover" ng-model="artists" >
                <tr>
                  <th>Name</th>
                  <th>Profile</th>
                  <th>First Name</th>
                  <th>Date</th>
                  <th>Status</th>
                  <th>Reknown</th>
                </tr>


                  <tr ng-repeat="item in artists" 
              style="cursor:pointer;">
                 <!--Actually it's not a name 
     and email, it's a chat box, I'm tyrying to build while click on   
     the visitors list, the chat box has to be displayed in the form of
     popup like facebook, gmail. but i'm new to angular.  -->
                        <modal title="Chat box" visible="showModal">
                            <form role="form">
                            <div class="form-group">
                            <label for="text">"name"</label>
                            <input type="text" class="form-control" 
             id="email" placeholder="Name" />
                            </div>
                            <div class="form-group">
                            <label for="password">Password</label>
                            <input type="password" class="form-control"
           id="password" placeholder="Password" />
                            </div>
                            <button type="submit" class="btn btn-
          default">Send</button>
                                </form>
                        </modal>

                  <td ng-click="toggleModal(artists.indexOf(item))" >
    <span value="{{artists.indexOf(item)}}"></span>{{item.name}}</a>
    </td>
                  <td ng-click="toggleModal()"><span value="
         {{artists.indexOf(item)}}">
                  </span><img ng-src="images/{{item.shortname}}_tn.jpg"
          width="35" height="35" alt="profile"></td>
                  <td ng-click="toggleModal()"><span value="
    {{artists.indexOf(item)}}"></span><h5>{{item.shortname}}</h5></td>
                  <td ng-click="toggleModal()"><span value="
            {{artists.indexOf(item)}}"></span>11-7-2014</td>
                  <td ng-click="toggleModal()"><span value="  
      {{artists.indexOf(item)}}"></span><span class="label label-
       success">Approved</span></td>
                  <td ng-click="toggleModal()"><span value="
         {{artists.indexOf(item)}}"></span>{{item.reknown}}</td>
                  <tr>

              </table>
              </div>
            </div>
          </div>
        </div>
      </div>
      </section>
      </div>



var myApp = angular.module('myApp', [
'ngRoute',
'myApp'
 ]);



 myApp.controller('ListController', ['$scope', '$http', 
 '$routeParams',  function($scope, $http, $routeParams) {
 $http.get('angular/data.json').success(function(data) {
  $scope.artists = data;
  $scope.artistOrder = 'name';
  $scope.whichItem = $routeParams.itemId;
  });
 }]);

myApp.controller('MainCtrl', ['$scope', '$http',
'$routeParams', function($scope, $http, $routeParams) {
$http.get('angular/data.json').success(function(data) {
$scope.showModal = false;
$scope.artists = data;
$scope.whichItem1 = $routeParams.itemId;
$scope.toggleModal = function(){
$scope.showModal = !$scope.showModal;

};
});
}]);



myApp.directive('modal', function () {
return {
  template: <!--In this place I want to pass my own coustomized 
    html which doesnot close on click outside -->
      '<div class="modal">' + 
      '<div class="modal-dialog">' + 
        '<div class="modal-content">' + 
          '<div class="modal-header">' + 
            '<button type="button" class="close" data-dismiss="modal" 
         aria-hidden="true">&times;</button>' + 
            '<h4 class="modal-title">{{ title }}</h4>' + 
          '</div>' + 
          '<div class="modal-body" ng-transclude></div>' + 
        '</div>' + 
       '</div>' + 
       '</div>',
      restrict: 'E',
     transclude: true,
     replace:true,
    scope:true,
    link: function postLink(scope, element, attrs) {
     scope.title = attrs.title;

     scope.$watch(attrs.visible, function(value){
      if(value == true)
        $(element).modal('show');
      else
        $(element).modal('hide');
    });

    $(element).on('shown.bs.modal', function(){
      scope.$apply(function(){
        scope.$parent[attrs.visible] = true;
      });
    });

    $(element).on('hidden.bs.modal', function(){

      scope.$apply(function(){
        scope.$parent[attrs.visible] = false;
      });
     });
          }
 };
 });

1 Comment

I want to use the popup like a chat box, it should not hide while click outside of the popup window.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.