Invoke function inside a controller from Fancybox2 - angularjs

I have this directive
app.directive('fancybox', function($compile, $timeout){
return {
link: function($scope, element, attrs){
$(element).fancybox({
'transitionIn': 'elastic',
'transitionOut': 'elastic',
'width': '250',
'height': '250',
'speedIn': 600,
'speedOut': 200,
'overlayShow': false,
afterLoad: function () {
$timeout(function(){
$compile($("#content-popup"))($scope);
$scope.$apply();
$.fancybox.resize();
})
this.title = $(this.element).next('.content-popup-footer').html();
},
helpers: {
title: {
type: 'inside'
}
},
});
}
}
});
I'm trying to invoke a function that is inside the controller that invoked the fancybox. This is the html that i'm sending to the fancybox
<a href="{{content.source}}" fancybox="fancybox" id="content-popup"
class="transparent-box content-popup content-picture-container"
rel="campaign-picture-popup" "><a/>
<!--Fancybox footer data begin-->
<div class="content-popup-footer" style="display:none">
<div class="row">
<div class="col-md-6 col-sm-6">
<div class="content-popup-user-info">
<img class="content_picture_profile_pic"
ng-src="{{content.photographer.instagramProfilePicture}}"/>
<div class="content_popup_user_name">
{{content.photographer.instagramUserName}}
</div>
<i class="fa fa-circle small-dot"></i>
<span id="instagram-picture-time-taken">{{content.timeTaken}}</span>
</div>
</div>
<div class="col-md-6 col-sm-6 content_popup_link_container">
<div class="content_popup_link">
<i class="fa fa-link"></i>
View source
</div>
</div>
</div>
<div class="row" id="content-popup-picture-info-row">
<div class="col-md-12">
<p>{{content.description}}</p>
</div>
<div class="col-md-12" id="content-popup-statistics">
<span><i class="fa fa-thumbs-o-up"></i>{{content.likesCount}}</span>
<span><i class="fa fa-comment-o"></i>{{content.commentsCount}}</span>
</div>
</div>
<form role="form">
<div class="form-body">
<div class="form-group">
<div class="input-icon">
<i class="fa fa-pencil-square-o"></i>
<input id="name" type="text" class="form-control"
placeholder="Add caption">
</div>
</div>
</div>
</form>
<div>
<button class="btn select-content-btn"
ng-click="onSelectedContent(content)"
ng-style="content.selected && {'background-color':'#2ecc71'} || !content.selected && {'background-color':'#95a5a6'}">
<i class="fa fa-check" ng-if="content.selected"></i>
<span ng-if="!content.selected">Select</span>
<span ng-if="content.selected">Selected</span>
</button>
</div>
</div>
</div>
<!--Fancybox footer data end-->
The problem that the scope doesn't being recognized inside the fancybox window and i can't invoke the onSelectedContent().
How can i add the scope to the fancybox window so i could activate all the scope's functions and props?

Related

AngularJS GitHub API| Conributors list in the repository list

I have a problem with the repository list in the list of all Conributors for this repository.
I want to create a Contributors list in the list of repositories downloaded using GitHub Api. However, I can not get these data for each repository and put them in html.
Has anyone any idea how to do this?
Thank you in advance for your help
My code:
App in html
<div ng-controller="gitApi" ng-app="app">
<div class="container">
<h1 class="text-center">
<span ng-hide="userData" />Loading</span>
<span />{{userData.name}}</span>
<br>
<a href="{{userData.html_url}}" class="btn btn-default">
{{userData.login}}
</a>
</h1>
<div class="panel panel-default">
<div class="panel-heading">
<form class="form-inline">
<span>
<h4>Repos <span class="badge">{{repoData.length}}</span>
<input ng-model="searchText" placeholder="Search" class="form-control input-sm">
</h4>
</span>
</form>
</div>
<div class="panel-body">
<div class="list-group">
<div ng-repeat="orgs in orgsData | filter:searchText | orderBy:predicate:reverse" class="list-group-item ">
<div class="row">
<div class="col-md-6">
<h4>
<a href="{{repo.html_url}}" target="_blank">
{{orgs.name}}
</a>
<small>{{orgs.description}}</small>
</h4>
<small>
<a href="{{orgs.homepage}}" class="">
<i class="fa fa-link"></i> WebPage
</a>
</small>
</div>
<div class="col-md-6">
Conributors List:
<div ng-repeat=" | filter:searchText | orderBy:predicate:reverse" class="list-group-item ">
<div class="row">
<div class="col-md-12">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
APP.js
angular.module('app', [])
.controller('gitApi', ['$scope', '$http', function($scope, $http) {
$scope.reposLoaded = false;
$scope.userLoaded = false;
$scope.orgsLoaded = false;
$http.get("https://api.github.com/users/angular")
.success(function(data) {
$scope.userData = data;
loadOrgsRepos();
});
var loadOrgsRepos = function() {
$http.get("https://api.github.com/orgs/angular/repos")
.success(function(data) {
$scope.orgsData = data;
});
}
$scope.predicate = '-updated_at';
}]);
You can get all contributors url from contributors_url and make an API call for each one of these, storing the result in the original $scope.orgsData array :
"use strict";
var githubApp = angular.module('app', []);
githubApp.controller('gitApi', ['$scope', '$http', '$q', function($scope, $http, $q) {
$http.get("https://api.github.com/users/angular")
.success(function(data) {
$scope.userData = data;
loadOrgsRepos();
});
var loadOrgsRepos = function() {
$http.get("https://api.github.com/orgs/angular/repos")
.success(function(data) {
$scope.orgsData = data;
var contribs = [];
for (var i in data) {
contribs.push(data[i].contributors_url);
}
$q.all(contribs.map(function(item) {
return $http({
method: 'GET',
url: item
});
}))
.then(function(results) {
results.forEach(function(val, i) {
$scope.orgsData[i].contributors = val.data;
});
});
});
}
$scope.repo_sort = '-updated_at';
$scope.contrib_sort = '-contributions'
}]);
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body id="page-top" class="index">
<div ng-controller="gitApi" ng-app="app">
<div class="container">
<h1 class="text-center">
<span ng-hide="userData">Loading</span>
<span>{{userData.name}}</span>
<br>
<a href="{{userData.html_url}}" class="btn btn-default">
{{userData.login}}
</a>
</h1>
<div class="panel panel-default">
<div class="panel-heading">
<form class="form-inline">
<span>
<h4>Repos <span class="badge">{{repoData.length}}</span>
<input ng-model="searchText" placeholder="Search" class="form-control input-sm">
</h4>
</span>
</form>
</div>
<div class="panel-body">
<div class="list-group">
<div ng-repeat="orgs in orgsData | filter:searchText | orderBy:repo_sort:reverse" class="list-group-item ">
<div class="row">
<div class="col-md-8">
<h4>
<a href="{{repo.html_url}}" target="_blank">
{{orgs.name}}
</a>
<small>{{orgs.description}}</small>
</h4>
<small>
<a href="{{orgs.homepage}}" class="">
<i class="fa fa-link"></i> WebPage
</a>
</small>
</div>
<div class="col-md-6">
Conributors List:
<div class="list-group-item">
<div class="row">
<div class="col-md-4">
name
</div>
<div class="col-md-4">
avatar
</div>
<div class="col-md-4">
contributions
</div>
</div>
</div>
<div ng-repeat="contrib in orgs.contributors | filter:searchText | orderBy:contrib_sort:reverse" class="list-group-item">
<div class="row">
<div class="col-md-4">
<a href="{{contrib.html_url}}" target="_blank">
{{contrib.login}}
</a>
</div>
<div class="col-md-4">
<img ng-src="{{contrib.avatar_url}}" height="42" width="42" />
</div>
<div class="col-md-4">
<p>
{{contrib.contributions}}
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
Here is another fiddle

Laravel - must be of the type array, none given

Having a strange problem with my laravel 5.2 build, I'm trying to send data from a form to my database and for some reason an error keeps being thrown on submit which states "Argument 1 passed to App\Http\Controllers\PostsController::postStatus() must be of the type array, none given" and I'm not sure why as I am sending data into an array. My code is shown below.
timeline.blade.php
#extends('layouts.app')
#section('content')
<div class="container-fluid">
<div class="row">
<div class="col-md-2">
<div class="row notifications-section">
<div class="col-md-4">
<div class="dropdown">
<a class="dropdown-toggle" type="button" data-toggle="dropdown">
<i class="fa fa-caret-square-o-down"></i></a>
<ul class="dropdown-menu">
<li>option 1</li>
</ul>
</div>
</div>
<div class="col-md-4">
<div class="dropdown">
<a class="dropdown-toggle" type="button" data-toggle="dropdown">
<i class="fa fa-comments"></i></a>
<ul class="dropdown-menu">
<li>option 1</li>
</ul>
</div>
</div>
<div class="col-md-4">
<div class="dropdown">
<a class="dropdown-toggle" type="button" data-toggle="dropdown">
<i class="fa fa-users"></i></a>
<ul class="dropdown-menu">
<li>option 1</li>
</ul>
</div>
</div>
</div>
</div>
<div class="col-md-5">
<form role="form" method="POST" action="{{ url('/home') }}" class="facebook-share-box">
{!! csrf_field() !!}
<div class="share">
<div class="panel panel-default">
<div class="panel-body">
<div class="">
<input type="hidden" name="user_name" value="{{ Auth::user()->firstName }} {{ Auth::user()->lastName }}">
<textarea name="body" cols="40" rows="10" id="status_message" value="{{ old('body') }}" class="form-control message" style="height: 62px; overflow: hidden;" placeholder="What's on your mind ?"></textarea>
</div>
<hr>
<div class="row">
<div class="col-md-7">
<div class="form-group">
<div class="btn-group">
<button type="button" class="btn btn-default"><i class="icon icon-map-marker"></i> Location</button>
<button type="button" class="btn btn-default"><i class="icon icon-picture" ></i> Photo</button>
</div>
</div>
</div>
<div class="col-md-5">
<div class="form-group">
<div class="row">
<div class="col-md-8">
<select name="visibility" class="form-control privacy-dropdown pull-left input-sm" value="{{ old('visibility') }}">
<option value="1" selected="selected">Public</option>
<option value="2">Only my friends</option>
<option value="3">Only me</option>
</select>
</div>
<div class="col-md-3">
<input type="submit" name="submit" class="btn btn-primary btn-small">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<div class="col-md-4 profile-section">
<div class="row">
<div class="col-md-8">
<h2>{{ Auth::user()->firstName }} {{ Auth::user()->lastName }}</h2>
<h4>{{ Auth::user()->currentLocation }}</h4>
<p>{{ Auth::user()->bio }}</p>
</div>
<div class="col-md-4">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-2 connect-section">
<div class="row">
<div class="col-md-4">Section</div>
<div class="col-md-4">Section</div>
<div class="col-md-4">Section</div>
</div>
</div>
<div class="col-md-9 posts-section">
<div class="row">
#foreach($posts as $post)
<div class="col-md-4">
<h2>{{ $post->user_name }}</h2>
{{ $post->created_at }}<br />
{{ $post->body }}
{{ $post->visibility }}<br />
<div class="row like_comment_share">
<div class="col-md-4">Like</div>
<div class="col-md-4">Comment</div>
<div class="col-md-4">Share</div>
</div>
</div>
#endforeach
</div>
</div>
</div>
</div>
#endsection
PostController.php
<?php
namespace App\Http\Controllers;
use App\Posts;
use App\Http\Controllers\Controller;
use Illuminate\Routing\Controller as BaseController;
class PostsController extends BaseController {
/**
* Display a listing of the resource.
*
* #return Response
*/
public function index()
{
}
public function display()
{
return view('users/timeline')
->with('user_name', 'body', 'photo', 'visibility', 'created_at')
->with('posts', Posts::all());
}
/**
* Show the form for creating a new resource.
*
* #return Response
*/
protected function postStatus(array $data)
{
return Posts::create([
'user_name' => $data['user_name'],
'body' => $data['body'],
'photo' => $data['photo'],
'visibility' => $data['visibility'],
]);
}
Post.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Posts extends Model
{
protected $fillable = [
'user_name', 'body', 'photo', 'visibility', 'created_at',
];
}
No data is passed to the controller when you post to a route. Instead, you access the data through the Request object by injecting it into the method, or by using the Request:: or Input:: facades.
protected function postStatus(Illuminate\Http\Request $request)
{
$data = $request->all();
return Posts::create([
'user_name' => $data['user_name'],
'body' => $data['body'],
'photo' => $data['photo'],
'visibility' => $data['visibility'],
]);
}

Passing firebase information through factory error

Alright my AngularJS Mates.. I need saving. The following is my code. As you can see i'm trying to like pass the firebase data through states, unfortunately 'Offer' is only displaying as '[]' I think this is because i'm using a $firebaseObject, but i just cant crack this code...
(yeah I totally stole a part of this from Codepen)
Legit i would get your address and send you roses if you fixed this for me.
My Factory:
.factory('PetService', function ($firebaseArray, $firebaseObject) {
var ref = new Firebase("https://idargo.firebaseio.com/userData")
var offer = ref.child('Offer');
var pets = [];
for (var i=0; i<100; i++) {
pets[i] = {
id: i,
'Name': 'Name' + i,
'Offer': $firebaseObject(offer)
};
}
return {
all: function () {
return pets;
},
get: function (petId) {
return pets[petId];
}
};
})
DashCtrl:
.controller('DashCtrl', function($scope, $state, $stateParams, PetService) {
$scope.pets = PetService.all();
})
ProfileCtrl:
.controller('ProfileCtrl', function($stateParams, PetService) {
$scope.pet = PetService.get($stateParams.petsId);
})
The State:
.state('app.profile', {
url: "/profile/:petsId",
views: {
'menuContent': {
templateUrl: "routes/profile.html",
controller: 'ProfileCtrl',
}
}
})
The Collection-Repeat:
<div class="col" collection-repeat="pet in pets" item-width="45%" item-height="35%" ui-sref="app.profile({petsId: pet.id })">
The Profile Html:
<div ng-cloak>
<ion-view title="{{pet.id}}">
<div class="bar bar-header loginbar">
<button class="button button-icon ion-ios-arrow-left loginhead" ui-sref="app.dash"></button>
<h1 class="title"></h1>
</div>
<ion-content>
<div>
<center>
<div class="top2">
<div class="wrapperinv">
<div style="padding-top: 15%"></div>
<div class="numberCircle">
<div class="height_fix"></div>
<div class="content"><img src="{{pet.Image}}" class="invoiceimage"></div>
</div>
<div style="margin-top: -100px;"></div>
<div class="mincirc">
<div style="margin-top: 8px;"></div>
<div class="rotate"><i class="icon ion-ios-telephone-outline invi"></i></div>
</div>
<div class="mincirc2" ui-sref="app.chat">
<div style="margin-top: 8px;"></div>
<div class="rotate"><i class="icon ion-ios-chatbubble-outline invi" ></i></div>
</div>
<div style="margin-top: 100px;"></div>
<label class="sometext">{{pet.firstName}}</label>
<div style="margin-top: -50px;"></div>
<h3>
<i class="ion-star invstar invi"></i> <i class="ion-star invstar invi"></i>
<i class="ion-star invstar invi"></i> <i class="ion-star invstar invi"></i>
<i class="ion-star invstar invi"></i>
</h3>
</div>
</div>
</div>
</center>
<div style="margin-top: -10px;"></div>
<div class="list" >
<label class="item item-icon-left">
<i class="icon ion-earth"></i>
<h4 class="invf">Location</h4>
<div class="invtext">{{pet.Name}}</div>
</label>
<label class="item item-icon-left">
<i class="icon ion-calendar"></i>
<h4 class="invf">Age</h4>
<div class="invtext">{{pet.Age}}</div>
</label>
<label class="item item-icon-left" style="word-wrap: break-word; width: 350px;">
<i class="icon ion-person"></i>
<h4 class="invf">About me</h4>
<div class="invtext" >{{item.About}}</div>
</label>
<label class="item item-icon-left">
<i class="icon ion-pizza"></i>
<h4 class="invf" >What I offer</h4>
<div class="invtext">{{pet.Offer}}</div>
</label>
<label class="item item-icon-left">
<i class="icon ion-cash"></i>
<h4 class="invf">Rate</h4>
<div class="invtext">{{item.Rate}}</div>
</label>
</div>
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d150038.30908416258!2d-74.00164182706976!3d40.64734690331712!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x89c24fa5d33f083b%3A0xc80b8f06e177fe62!2sNew+York%2C+NY%2C+USA!5e1!3m2!1sen!2sau!4v1440975673055" width="400" height="300" frameborder="0" style="border:0"></iframe>
<button class="button button-block invbut" ng-click="invoice()">
Book With {{item.Name}}
</button>
</div>
</div>
</ion-content>
</ion-view>
</div>
Thanks in advance!
-Sorry if my English is bad... i'm from Australia.

AngularJS 'fn' is not a function

Here is my front-end code:
<div class="wrapper wrapper-content animated fadeIn text-center" ng-controller="ProjectCtrl">
<div class="row row-centered">
<div ng-repeat="project in _projects">
<div class="project-container col-lg-3 col-md-4 col-sm-6 col-centered text-center">
<div class="project-thumb-container">
<div class="project-thumb" style="background-image: url('img/project{{project.projectid}}.jpg');">
<div class="inner-arrow" ui-sref="portal.dashboard({ projectid: {{project.projectid}} })">
<span class="icon-arrow-right fa-5x"></span>
</div>
<div class="project-settings like-link">
<span class="fa fa-gear fa-2x" ng-click="open('test')"></span>
</div>
<div class="project-share like-link">
<span class="fa fa-users fa-2x" ng-click="open('test')"></span>
</div>
</div>
</div>
<h2>{{project.title}}</h2>
</div>
</div>
<div class="project-container col-lg-3 col-md-4 col-sm-6 col-centered text-center">
<div class="project-thumb-container">
<div class="project-thumb thumb-new">
<div class="plus-icon-container">
<span class="fa fa-plus fa-5x"></span>
</div>
</div>
</div>
<h4><i>Add Project</i></h4>
</div>
</div>
</div>
And here is my controller:
'use strict';
angular.module('controllers', ['Projects']).controller('ProjectCtrl', function($scope, Projects) {
var _self = this;
_self.error = null;
_self.processing = true;
Projects.getProjectList().then(function(data){
$scope._projects = data;
}).catch(function(err) {
_self.error = true;
_self.processing = false;
});
});
Here is my route:
.state('root.projects', {
url: "/projects",
controller: "ProjectCtrl as ProjectCtrl",
templateUrl: "views/projects.html",
})
When that code is ran on the front-end, I keep getting this error: Error: [ng:areq] Argument 'ProjectCtrl' is not a function, got undefined

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