Mantain style of modal with ui.bootstrap modals - angularjs

I'm using a Bootstrap modal to show details of selected items.
I have a snippet of my modal window that i want to make appear.
If i use it as a modal template I have issues with the style.
But if I trigger the modal window as a normal modal, not a ui.bootstrap one, everything works fine. This are my files:
App.js
var app = angular.module('app', ['ui.router', 'ui.bootstrap']);
app.config(['$urlRouterProvider', '$stateProvider', function($urlRouterProvider, $stateProvider){
$urlRouterProvider.otherwise('/');
$stateProvider.state('home', {
url: '/',
templateUrl: 'productos/productos.html'
});
}]);
app.controller('ModalCtrl', function($scope, $uibModal) {
$scope.items = [{
nombre: 'Federico Ribero',
thumb: 'http://placehold.it/369x246',
desc_corta: 'Esto es la decripcion corta de Fede',
descripcion: 'Esto es la descripcion de Fede'
},{
nombre: 'Camila Nosotti',
thumb: 'http://placehold.it/369x246',
desc_corta: 'Esto es la decripcion corta de Cami',
descripcion: 'Esto es la descripcion de Cami'
},{
nombre: 'Juliana Ribero',
thumb: 'http://placehold.it/369x246',
desc_corta: 'Esto es la decripcion corta de Juli',
descripcion: 'Esto es la descripcion de Juli'
}]
$scope.showModal = function(selectedItem) {
var uibModalInstance = $uibModal.open({
templateUrl : 'modalContent.html',
controller : function($scope, $uibModalInstance, $uibModal, item){
$scope.item = item;
},
resolve: {
item: function(){
return selectedItem;
}
} // empty storage
});
uibModalInstance.result.then(function(selectedItem){
$scope.selected = selectedItem;
},function(){
//on cancel button press
console.log("Modal Closed");
});
};
});
View with modal
<!-- ====PROTFOLIO AREA==== -->
<section id="Portfolio" class="protfolio_area section-padding" ng-controller="ModalCtrl">
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="work_trigge">
<ul class="trigger mb80 text-center">
<li class="filter active" data-filter="">ALL</li>
<li class="filter" data-filter=".html">HTML</li>
<li class="filter" data-filter=".wordpress">Wordpress</li>
<li class="filter" data-filter=".ui_ux">UI/UX</li>
<li class="filter" data-filter=".print">PRINT</li>
</ul>
</div>
</div>
</div>
<div class="row">
<div ng-repeat="item in items">
<!--First column-->
<div class="col-lg-4 col-md-12 mb-r">
<!--Card-->
<div class="card card-cascade wider">
<!--Card image-->
<div class="view overlay hm-white-slight">
<img ng-src="{{item.thumb}}" class="img-fluid" alt="">
<a>
<div class="mask"></div>
</a>
</div>
<!--/.Card image-->
<!--Card content-->
<div class="card-block text-xs-center">
<!--Category & Title-->
<h5>Shoes</h5>
<h4 class="card-title"><strong><a ng-click="ModalCtrl.showModal(item)">{{item.nombre}}</a></strong></h4>
<!--Description-->
<p class="card-text">{{item.desc_corta}}
</p>
<!--Card footer-->
<div class="card-footer">
<span class="left"><a class="" data-toggle="tooltip" data-placement="top" title="Ver más" ng-click="showModal(item)">Ver más <i class="fa fa-eye"></i></a>
</span>
<span class="right">
<a class="" data-toggle="tooltip" data-placement="top" title="Marcar como favorito"><i class="fa fa-heart"></i></a>
</span>
</div>
</div>
<!--/.Card content-->
</div>
<!--/.Card-->
</div>
<!--/First column-->
</div>
</div>
<div class="row">
<div class="col-xs-12 trigger_bottom">
<a href="#!" class="th_bt btn waves-effect waves-light">View All
<i class="zmdi zmdi-long-arrow-right"></i>
</a>
</div>
</div>
</div>
</section>
<!-- ====END PROTFOLIO AREA==== -->
Modal triggered by javascript with no style problems
<!-- Modal -->
<div class="modal fade ql-modal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<!--Content-->
<div class="modal-content">
<!--Header-->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myModalLabel">Vista completa del artículo</h4>
</div>
<!--Body-->
<div class="modal-body">
MY MODAL CONTENT GOES HERE.......
</div>
<!--Footer-->
<div class="modal-footer">
<a class="btn btn-default">Ask about details</a>
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
<!--/.Content-->
</div>
</div>
<!--/Modal-->
<script type="text/javascript">
$("#myModal").modal("show")
</script>
UI Bootstrap Modal.
<script type="text/ng-template" id="modalContent.html">
<!-- Modal -->
<div class="modal-dialog" role="document">
<!--Content-->
<div class="modal-content">
<!--Header-->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myModalLabel">Vista completa del artículo</h4>
</div>
<!--Body-->
<div class="modal-body">
MY MODAL CONTENT GOES HERE.......
</div>
<!--Footer-->
<div class="modal-footer">
<a class="btn btn-default">Ask about details</a>
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
<!--/.Content-->
</div>
<!--/Modal-->
</script>
I dont know if you note the first line of my original Modal is:
<div class="modal fade ql-modal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
If i remove that line from ui.bootstrap modal, my modal style have issues.
If i add that line to ui.bootstrap modal, my modal window dont appear.
Just show the shadow behind the "panel appeared" but nothing shows up
I hope you could understand my problem. Thanks a lot.
UPDATE 1

It looks like you need to add your class to the top window template of the modal. Luckily, UI Bootstrap provides the windowTopClass property, that allows you to add your class to it:
var modalInstance = $uibModal.open({
windowTopClass: 'ql-modal',
templateUrl : 'modalContent.html',
controller : function($scope, $uibModalInstance, $uibModal, item){
$scope.item = item;
},
resolve: {
item: function(){
return selectedItem;
}
} // empty storage
});
Also, there is no need to include the modal dialog container, or the content container:
<div class="modal-dialog" role="document">
<div class="modal-content"></div>
</div>
This is already included by default in UI Bootstrap. If you look at the source code for the library, you will see the window template (https://github.com/angular-ui/bootstrap/blob/master/template/modal/window.html) already includes this container:
<div class="modal-dialog {{size ? 'modal-' + size : ''}}"><div class="modal-content" uib-modal-transclude></div></div>
Also, if you want to make changes to this window tempalte, UI Bootstrap provides another property windowTemplateUrl where you can provide your own template:
var modalInstance = $uibModal.open({
windowTopClass: 'ql-modal',
windowTemplateUrl: 'windowTemplate.html',
templateUrl : 'modalContent.html',
controller : function($scope, $uibModalInstance, $uibModal, item){
$scope.item = item;
},
resolve: {
item: function(){
return selectedItem;
}
} // empty storage
});

Related

ng-repeat not displaying inside modal

I have this modal here
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Details</h4>
</div>
<div class="modal-body">
<div class="row" ng-repeat="prods in products">
<div class="col-sm-4">
<p>#{{prods.pd }}</p>
</div>
<div class="col-sm-4">
<p>#{{ prods.quantity }}</p>
</div>
<div class="col-sm-4">
<p>#{{ prods.totalline }}</p>
</div>
</div>
</div>
</div>
</div>
</div>
I show my model clicking in a button
<button id="btn-add" class="btn btn-primary btn-sm" ng-click="toggle()"> View Details <i class="fa fa-plus" aria-hidden="true" style="margin-left: 50px; margin-right: 20px"></i></button>
And im trying to display some data.
My controller js is like this
app.controller('productDelivedController', function($scope, $http, API_URL) {
$scope.toggle = function() {
$http.get(API_URL + 'donation/listLines/1')
.success(function(response) {
$scope.products = response;
});
$('#myModal').modal('show');
}});
Probably im doing something wrong but i dont know what, im receiving the data correctly like i was supose to but i just cant update my modal with that data.
Please try the modal show code in success function, you are displaying the dialog, before data loaded.
If you show the modal after the data loaded, then the problem will not happed.
app.controller('productDelivedController', function($scope, $http, API_URL) {
$scope.toggle = function() {
$http.get(API_URL + 'donation/listLines/1')
.success(function(response) {
$scope.products = response;
$('#myModal').modal('show');
});
}});

How to stop Angular $timeout when bootstrap modal opens and resume after the modal closes?

I have this code that fetches data from db every 1 second:
app.controller("rfController", ['$scope', '$http', '$timeout', function ($scope, $http, $timeout) {
$scope.displayData = function () {
$http.get('db.php').success(function(data) {
$scope.refreshes = data;
console.log(data);
});
$timeout(function() {
$scope.displayData();
},1000)
};
}]);
But the problem is that I have some buttons that open up bootstrap modals to look into these data. When I open the modal, it keeps closing because the displayData() function keeps refreshing. Here is the html for modal:
<div class="col-md-4 text-right">
<button class="btn rf-btn" id="clicked" data-toggle="modal" data-target="#rfmodal{{$index}}">More</button> <!-- OPENS MODAL -->
<!-- MODAL -->
<div class="modal small fade" tabindex="-1" role="dialog" id="rfmodal{{$index}}">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header"
ng-class="{'bg-success': refresh.status === 'Successful',
'bg-fail': refresh.status === 'Failed',
'bg-delay': refresh.status === 'Delayed'}">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title text-center">{{refresh.company}}</h4>
</div>
<div class="modal-body text-left">
<p class="detail-text"><b>Status</b>: {{refresh.status}}</p>
<p class="detail-text"><b>TimeStamp</b>: {{refresh.dt}}</p>
<p class="detail-text"><b>OrgID</b>: {{refresh.orgid}}</p>
<p class="detail-text"><b>Body</b>: {{refresh.body}}</p>
</div>
<div class="modal-footer">
<button type="button rf-btn" class="btn rf-btn" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
Any ideas?
In controller your variable name is $scope.refreshes.
In html you are fetching data from "refresh" .Could be a problem??
Also $timeout delays the execution of the function, it won't repeatedly call the displaydata function every 1 second.It will only call it once after a second.
You should use $interval instead.
Try This. This will stop the interval when modal is open.
And you have to use setInterval to call the function repeatedly ,
$timeout only executes once after given time.
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<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>
<body>
<div ng-app="myApp" ng-controller="rfController">
<div class="col-md-4 text-right">
<button class="btn rf-btn" id="clicked" ng-click="runInterval = false" data-toggle="modal" data-target="#rfmodal{{$index}}" data-backdrop="static" data-keyboard="false">More</button> <!-- OPENS MODAL -->
<!-- MODAL -->
<div class="modal small fade" tabindex="-1" role="dialog" id="rfmodal{{$index}}">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header"
ng-class="{'bg-success': refresh.status === 'Successful',
'bg-fail': refresh.status === 'Failed',
'bg-delay': refresh.status === 'Delayed'}">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title text-center">{{refresh.company}}</h4>
</div>
<div class="modal-body text-left">
<p class="detail-text"><b>Status</b>: {{refresh.status}}</p>
<p class="detail-text"><b>TimeStamp</b>: {{refresh.dt}}</p>
<p class="detail-text"><b>OrgID</b>: {{refresh.orgid}}</p>
<p class="detail-text"><b>Body</b>: {{refresh.body}}</p>
</div>
<div class="modal-footer">
<button type="button rf-btn" class="btn rf-btn" data-dismiss="modal" ng-click="runInterval = true">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
var app = angular.module('myApp', []);
app.controller("rfController", ['$scope', '$http', '$timeout', function ($scope, $http, $timeout) {
$scope.runInterval = true;
$scope.displayData = function () {
$http.get('http://localhost').success(function(data) {
$scope.refreshes = data;
console.log(data);
});
console.log("displayData");
};
setInterval(function() {
if($scope.runInterval){
$scope.displayData();
console.log("Done");
}
},1000)
}]);
</script>
</body>
</html>

Modal window does not popup on ng-click

I'm trying to add a modal popup window to my Angular app. Although it lists down the names, when I click on the names a modal doesn't appear. Below is my code
HTML:
<div ng-app="app">
<div ng-repeat="customer in customers">
<button class="btn btn-default" ng-click="open(customer)">{{ customer.name }}</button> <br />
<!--MODAL WINDOW-->
<script type="text/ng-template" id="myContent.html">
<div class="modal-header">
<h3>The Customer Name is: {{ customer.name }}</h3>
</div>
<div class="modal-body">
This is where the Customer Details Goes<br />
{{ customer.details }}
</div>
<div class="modal-footer">
</div>
</script>
</div>
</div>
JS:
var app = angular.module('app', ['ngRoute','ui.bootstrap']);
app.config(function($routeProvider) {
$routeProvider.
when('/', {controller:testcontroller, templateUrl:'http://localhost/app/index.php/customer/home'}).
otherwise({redirectTo:'/error'});
});
function test2controller ($scope, $modalInstance, customer) {
$scope.customer = customer;
}
function testcontroller ( $scope, $timeout, $modal, $log) {
$scope.customers = [
{
name: 'Ben',
details: 'Some Details for Ben',
},
{
name: 'Donald',
details: 'Some Donald Details',
},
{
name: 'Micky',
details: 'Some Micky Details',
}
];
$scope.open = function (_customer) {
var modalInstance = $modal.open({
controller: "test2controller",
templateUrl: 'myContent.html',
resolve: {
customer: function()
{
return _customer;
}
}
});
};
}
Can someone let me know what am I doing wrong here?
Controller
$scope.saveFeed = function(feed){
$('#exampleModalCenter').modal('show');
console.log(feed);
}
HTML
<a class="dropdown-item p-3" href="#" ng-click="saveFeed(feed.id)">
<div class="d-flex align-items-top">
<div class="icon font-size-20"><i class="ri-save-line"></i>
</div>
<div class="data ml-2">
<h6>Save Post</h6>
<p class="mb-0">Add this to your saved items</p>
</div>
</div>
</a>
<!-- Modal -->
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalCenterTitle">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>

Modal window has large background

I am using the iu.bootstrap.modal popup window on one of my views. The modal windows displays correctly except that it looks like it is inside a larger white frame.
What is causing this white frame to appear behind my modal window?
Here is my view:
<button type="button" id="btnModal" name="modal1" ng-click="openModal()" class="btn btn-primary pull-right">Open Modal</button>
<!--Modal-->
<script type="text/ng-template" id="myModal.html">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">{{title}}</h3>
</div>
<div class="modal-body">
<span id="error-message" class="text-danger" style="white-space:pre">{{message}}</span>
</div>
<div class="modal-footer">
<button id="btn-ok" class="btn btn-primary" type="button" ng-click="ok()">OK</button>
</div>
</div>
</script>
And my controller
$scope.openModal = function () {
var title = "Modal Title";
var message = "Modal Message";
var modalInstance = $uibModal.open ({
animation: true,
templateUrl: 'myModal.html',
size: 'sm',
controller: function ($scope) {
$scope.title = title;
$scope.message = message;
$scope.ok = function () { modalInstance.dismiss() };
}
});
};
What causes the window to appear behind the modal?
In ui.bootstrap documentation (https://angular-ui.github.io/bootstrap/#/modal)
<script type="text/ng-template" id="myModalContent.html">
<div class="modal-header">
<h3 class="modal-title" id="modal-title">I'm a modal!</h3>
</div>
<div class="modal-body" id="modal-body">
<ul>
<li ng-repeat="item in $ctrl.items">
{{ item }}
</li>
</ul>
Selected: <b>{{ $ctrl.selected.item }}</b>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="button" ng-click="$ctrl.ok()">OK</button>
<button class="btn btn-warning" type="button" ng-click="$ctrl.cancel()">Cancel</button>
</div>
</script>
There is not a <div> of modal-content class. But you have at the beginning of the modal. The modal-content is a css Bootstrap class and it may cause the problem.

Closing all open Bootstrap modals in AngularJS?

I have created a modal that opens another modal. I want to use the second modal as a confirmation box to close the first one. I cant get it to close both modals when I click ok on the confirmation box (the second modal).
Tree.html:
<script type="text/ng-template" id="tree_item_renderer.html">
<div class="bracket-match" ng-class="match.tier == 1 ? 'bracket-match-final' : ''">
<p ng-show="match.tier == 1" class="finale-title">Finale</p>
<div class="match-content">
<div class="player-div">
<div class="bracket-player-1 bracket-player-1-tier-{{tierCount+1-match.tier}}">
<input class="input-player-1 input-player-name form-control" type="text" ng-model="match.player1" placeholder="Deltager 1">
</div>
</div>
<div class="player-div border-bottom">
<div class="bracket-player-2">
<input class="input-player-2 input-player-name form-control" type="text" ng-model="match.player2" placeholder="Deltager 2">
</div>
</div>
</div>
<div ng-show="match.tier == 1 && showthirdplace && tierCount >= 2" class="third-place" ng-model="thirdplace">
<p class="finale-title">3. plads</p>
<div class="match-content">
<div class="player-div">
<div class="bracket-player-1 bracket-player-1-tier-{{tierCount+1-match.tier}}">
<input class="input-player-1 input-player-name form-control" type="text" ng-model="match.player1" placeholder="Deltager 1">
</div>
</div>
<div class="player-div border-bottom">
<div class="bracket-player-2">
<input class="input-player-2 input-player-name form-control" type="text" ng-model="match.player2" placeholder="Deltager 2">
</div>
</div>
</div>
</div>
</div>
<div class="bracket-column">
<div ng-repeat="match in match.previousMatches" ng-include="'tree_item_renderer.html'" />
</div>
</script>
<script type="text/ng-template" id="tournament-tree.html">
<div class="row modal-footer-btns">
<button class="btn btn-primary" ng-click="ok()">GEM</button>
<button class="btn btn-warning btn-xs" ng-click="openAlertBox()" type="button" data-dismiss="modal">LUK, uden at gemme</button>
</div>
<div class="row" style="margin-bottom:15px;">
<a ng-click="addMatchTier()" class="btn btn-primary"><i class="glyphicon glyphicon-plus"></i></a>
<a ng-click="removeMatchTier()" ng-class="tierCount > 1 ? 'btn btn-primary' : 'btn btn-default'"><i class="glyphicon glyphicon-minus"></i></a><br />
</div>
<div class="row tournament-tree">
<div ng-repeat="match in finalMatch">
</div>
<div class="bracket-column">
<div ng-repeat="match in finalMatch" ng-include="'tree_item_renderer.html'"></div>
</div>
</div>
</script>
<script type="text/ng-template" id="openAlertBox.html">
<div class="modal-header">
<h3 class="modal-title"></h3>
</div>
<div class="modal-body"> </div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="ok()">Ja</button>
<button class="btn btn-warning" ng-click="cancel()">Annuller</button>
</div>
</script>
Categories.html:
<div class="row">
<div class="modal-header">
<h3 class="modal-title"></h3>
</div>
</div>
<div ng-controller="CategoriesController">
<a ng-click="add()" class="btn btn-tree btn-primary" style="margin-top:15px;">Tilføj hovedkategori</a>
<p ng-repeat="data in nodes" ng-include="'category_item_renderer.html'"></p>
<ng-include src="'Modules/TournamentTree/Tree.html'"></ng-include>
</div>
<script type="text/ng-template" id="category_item_renderer.html">
<div class="category-style">
<div class="push-cat-btn">
<a ng-click="add(data)" class="btn btn-primary btn-sm"><i class="glyphicon glyphicon glyphicon-plus"></i></a>
<a ng-hide="data.nodes.push()" ng-click="openTournamentTree(data)" class="btn btn-info btn-xs">Turnering</a>
</div>
</div>
<p class="push" ng-repeat="data in data.nodes" ng-include="'category_item_renderer.html'"></p>
</script>
<script type="text/ng-template" id="TournamentTreeModal.html">
<div class="modal-header">
<h3 class="modal-title"></h3>
</div>
<div class="modal-body">
<div class="include-tree" ng-include="'tournament-tree.html'"></div>
</div>
<div class="modal-footer">
</div>
</script>
TreeController.js:
angular.module('tournamentTree', ['ui.bootstrap']);
angular.module('tournamentTree').controller("TreeController", ['$scope', '$modal', '$modalInstance', 'guidGenerator', function ($scope, $modal, $modalInstance, guidGenerator) {
$scope.openAlertBox = function () {
var alertBoxInstance = $modal.open({
templateUrl: 'openAlertBox.html',
controller: 'TreeController',
scope: $scope,
size: 'xs',
resolve: {
}
});
};
$scope.ok = function () {
$scope.close();
$scope.$parent.close();
}
$scope.cancel = function () {
$scope.close();
$scope.$parent.dismiss('cancel');
};
categoriController.js:
angular.module('tournamentCategories').controller("CategoriesController",
['$scope', '$modal', 'guidGenerator', 'eventBus', domainName + "Service", 'TournamentCategoryModelFactory',
function ($scope, $modal, guidGenerator, eventBus, domainService, modelFactory) {
$scope.openTournamentTree = function () {
var modalInstance = $modal.open({
templateUrl: 'TournamentTreeModal.html',
controller: 'TreeController',
scope: $scope,
size: 'wide-90',
backdrop: 'static',
keyboard: false,
resolve: {
}
});
modalInstance.result.then(function (selectedItem) {
//$scope.selected = selectedItem;
}, function () {
//$log.info('Modal dismissed at: ' + new Date());
});
};
}]);
You can use $modalStack from ui.bootstrap to close all instances of $modalInstance
$modalStack.dismissAll(reason);
This is how i got it working in my project without using any factory or additional code.
//hide any open bootstrap modals
angular.element('.inmodal').hide();
I have a timeout function that emits logout as $rootScope.$emit('logout'); and the listener in my service is as follows:
$rootScope.$on('logout', function () {
//hide any open bootstrap modals
angular.element('.inmodal').hide();
//do something else here
});
If you want to hide any other modals such as angular material dialog ($mdDialog) & sweet alert dialog's use angular.element('.modal-dialog').hide(); & angular.element('.sweet-alert').hide();
I don't know if this is the right approach , but it works for me.

Resources