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!
-
Some code? Fiddle? Something you have tried / researched?SD.– SD.2015-07-10 09:04:43 +00:00Commented Jul 10, 2015 at 9:04
-
what do you mean "popup"? is that alert kind of or customized HTML popup?Prabhu Vignesh Rajagopal– Prabhu Vignesh Rajagopal2015-07-10 09:09:55 +00:00Commented Jul 10, 2015 at 9:09
-
customized html popup and here is my codeSen– Sen2015-07-10 09:49:48 +00:00Commented Jul 10, 2015 at 9:49
Add a comment
|
2 Answers
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'})
2 Comments
Sen
This is my code and I want popup my coustomized html without closing automatically
dieuvn3b
why dont you use the modal of angular-bootstrap angular-ui.github.io/bootstrap/#/modal
<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">×</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
Sen
I want to use the popup like a chat box, it should not hide while click outside of the popup window.