I have a problem with bootstrap validator,
i have a angularjs project where i have a form in a modal in a directive.
so, i want when the modal hides, reset the form to the validator reset.
But when i use :
$('#StandardForm').bootstrapValidator('resetForm', true);
nothing is happening, when i recall my form modal, the validators is always here.(the inputs are green(good) or red(not good)).
see my directive :
angular.module('app.administration').directive('wcStandardForm',['servicesHTTP', function(servicesHTTP)
{
return {
restrict: 'E',
scope: {
standard: '=',
method: '&'
},
replace: true,
templateUrl: 'app/administration/directives/standard/wc-standard-form.tpl.html',
link: function(scope, form)
{
form.bootstrapValidator({
framework: 'bootstrap',
excluded: ':disabled',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
name: {
validators: {
notEmpty: {
message: 'le nom est nécessaire.'
},
stringLength: {
max: 31,
message: 'Le nom ne doit pas dépasser 31 caractères.'
}
}
}
}
});
},
controller: function($scope)
{
/**
* Vide le moduleForm
*/
$scope.clearStandardForm = function()
{
//$scope.standard = {};
$('#StandardForm').bootstrapValidator('resetForm', true);
};
/**
* Valide le module et envoi la requete http
*/
$scope.validateStandardForm = function()
{
...
$scope.clearStandardForm();
};
}
};
}]);
and here the template :
<div class="modal fade" id="standardFormModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true" ng-click="clearStandardForm()">×</span>
<span ng-click="clearStandardForm()" class="sr-only">Close</span>
</button>
<h4 class="modal-title">Assigner fonctions</h4>
</div>
<div class="modal-body">
<form id="StandardForm" method="post" class="ng-pristine ng-valid bv-form" novalidate="novalidate">
<button type="submit" class="bv-hidden-submit" style="display: none; width: 0px; height: 0px;"></button>
<div class="form-group">
<label class="control-label">Nom</label>
<input type="text" class="form-control" name="name" ng-model="standard.standard_name">
</div>
<div class="form-actions">
<div class="row">
<div class="col-md-12">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-click="clearStandardForm()">Close</button>
<button type="submit" class="btn btn-primary"data-dismiss="modal" ng-click="validateStandardForm()"><i class="fa fa-save"></i> Sauvegarder</button>
</div>
</div>
</div>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
I tried to do the $('#StandardForm').bootstrapValidator('resetForm', true); on the event show.bs.modal et hidden.bs.modal of the modal and the same things.
So if you have a idea, i will take it :)
Looking at your code, found this mistake id="StandardF orm" (if it's not typo)
<form id="StandardF orm" method="post" class="ng-pristine ng-valid bv-form" novalidate="novalidate">
Where the selector use in JS is $('#StandardForm')
Second if you look at the Reference here, alternate way to resets the form fields which have validator rules is $(form).data('bootstrapValidator').resetForm();
$('#StandardForm').data('bootstrapValidator').resetForm(true);
Related
Hello my fellow stackoverflowers,
I guess i have a simple question.
In my html i have a Modal Dialog that pops up. It uses ng2 Bootstrap. It works and all but... I want this code
"<button class="btn btn-primary" (click)="showModal()">Login</button>"
(showModal())
replace it in my ts file as a function
showModal(modal: ModalDirective) {
}
How can i do this? i am already struggling more then a hour.
This is my full HTML Code.
<button class="btn btn-primary" (click)="showModal()">Login</button>
<!-- Modal -->
<div bsModal #lgModal="bs-modal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" (click)="lgModal.hide()" aria-label="Close">
<span aria-hidden="true"> ×</span>
</button>
<h4 class="modal-title">Login</h4>
</div>
<div class="modal-body">
<form id="myForm" role="form" [ngFormModel]="CreateGroup">
<div class="form-group">
<div class="input-group">
<input type="text" [(ngModel)]='demoInfo.name' class="form-control" ngControl='name' placeholder="Gebruikersnaam">
<label for="uLogin" class="input-group-addon glyphicon glyphicon-user"></label>
</div>
</div>
<div class="form-group">
<div class="input-group">
<input type="password" [(ngModel)]='demoInfo.password' class="form-control" ngControl='password' placeholder="Wachtwoord">
<label for="uPassword" class="input-group-addon glyphicon glyphicon-lock"></label>
</div>
</div>
</form>
<div class="modal-footer">
<button type="button" [disabled]='!CreateGroup.valid' (click)="addNewGroup(demoInfo)" class="btn btn-primary">Login</button>
</div>
</div>
</div>
</div>
and hits is my full TS code
import { Component } from '#angular/core';
import { ROUTER_DIRECTIVES } from '#angular/router';
import { CORE_DIRECTIVES, FORM_DIRECTIVES, Control, ControlGroup, FormBuilder } from '#angular/common';
import { ModalDirective, BS_VIEW_PROVIDERS} from 'ng2-bootstrap/ng2-bootstrap';
class DemoInfo {
name: string;
password: string;
}
#Component({
template: require('./template.component.html'),
directives: [FORM_DIRECTIVES, CORE_DIRECTIVES, ModalDirective],
viewProviders: [BS_VIEW_PROVIDERS]
})
export class ModalComponent {
CreateGroup: ControlGroup;
demoInfo: DemoInfo;
modal: ModalDirective;
constructor(fb: FormBuilder) {
this.demoInfo = new DemoInfo();
this.CreateGroup = fb.group({
'name': new Control(this.demoInfo.name),
'password': new Control(this.demoInfo.password)
})
}
addNewGroup(demoInfo: DemoInfo) {
console.log(demoInfo, 'whole object');
this.demoInfo = new DemoInfo();
}
showModal(modal: ModalDirective) {
}
hideModal(modal: ModalDirective) {
}
}
So this is what i did.
I added #ViewChild('lgModal') modal: any; in my ModalComponent
made a new function called showModal()
and referenced it by calling this.modal.dosomething();
I was making a small "Reading List" application following guides of Soup to Bits: Shaping up with Angular.js video
I didn't like the way they put "Cancel" button at the top and just for practice decided to move it inside the form. I figured out how to make it work (click on 'Cancel' hid the form using expression ng-click="reviewFormCtrl.showForm = false"). It worked until guys from CodeSchool made an isolated scope
directive('reviewForm', function(){
return {
restrict: "E",
templateUrl: "partials/review-form.html",
replace: true,
controller: function() {
this.showForm = false;
this.book = {genres:{}};
this.addReview = function(form) {
books.push(this.book);
this.book = {genres:{}};
form.$setPristine();
}
},
controllerAs: 'reviewFormCtrl',
scope: {
books: '=',
genres: '='
}
}
})
From that point my 'Cancel' button stopped working. Console says that ReviewFormCtrl and ReviewFormCtrl.showForm are undefined. I can't figure out how to change that value from inside the scope I'm in.
Below is my app.html and app.js
(function() {
'use strict';
// Declare app level module which depends on views, and components
angular.module('readingList', []).
controller('ReadingListController', function(){
this.books = books;
this.genres = genres;
}).
directive('bookGenres', function(){
return {
restrict: "E",
templateUrl: "partials/book-genres.html",
scope: {
genres: "="
}
}
}).
directive('bookCover', function(){
return {
restrict: "E",
templateUrl: "partials/book-cover.html",
replace: true
}
}).
directive('reviewForm', function(){
return {
restrict: "E",
templateUrl: "partials/review-form.html",
replace: true,
controller: function() {
this.showForm = false;
this.book = {genres:{}};
this.addReview = function(form) {
books.push(this.book);
this.book = {genres:{}};
form.$setPristine();
}
},
controllerAs: 'reviewFormCtrl',
scope: {
books: '=',
genres: '='
}
}
})
;
var genres = [ 'fable', 'fantasy', 'fiction', 'folklore', 'horror', 'humor', 'legend', 'metafiction', 'mystery', 'mythology', 'non-fiction', 'poetry' ];
var books = [
{
title: 'A Game of Thrones: A Song of Ice and Fire',
author: 'George R.R. Martin',
isbn: '0553593714',
review: 'The most inventive and entertaining fantasy saga of our time—warrants one hell of an introduction. I loved this book!',
rating: 4,
genres: { 'non-fiction': true, fantasy: true }
},{
title: 'HTML for Babies',
author: 'John C Vanden-Heuvel Sr',
isbn: '0615487661',
review: "It's never too early to be standards compliant! I taught my little one mark-up in under one hour!",
rating: 5,
genres: { fiction: true }
},{
title: 'A is for Array',
author: 'Brandon J Hansen',
isbn: '1489522212',
review: 'A is for Array is the ABC book for future programmers. Filled with fun illustrations and simple real-world examples, my children loved seeing my world intertwined with theirs!',
rating: 4,
genres: { fiction: true }
},{
title: 'The Dragon Reborn',
author: 'Robert Jordan',
isbn: '0812513711',
review: 'The Wheel weaves as the Wheel wills, and we are only the thread of the Pattern. Moiraine',
rating: 4,
genres: { 'non-fiction': true, fantasy: true }
}
];
})();
<h1>Angular Reading List of Awesome</h1>
<div class="row" ng-controller="ReadingListController as readingListCtrl">
<button class="btn btn-default" ng-click="reviewFormCtrl.showForm = !reviewFormCtrl.showForm" ng-hide="reviewFormCtrl.showForm">{{reviewFormCtrl.showForm ? "Cancel" : "Create a Review"}}</button>
<hr />
<review-form books="readingListCtrl.books" genres="readingListCtrl.genres" ng-show="reviewFormCtrl.showForm"></review-form>
<hr ng-show="reviewFormCtrl.showForm"/>
<ul class="list-unstyled col-sm-8">
<li class="book row" ng-repeat="book in readingListCtrl.books">
<!-- Book cover goes here -->
<book-cover></book-cover>
<div class="col-sm-9">
<h3>{{book.title}}</h3>
<cite class="text-muted">Written by {{book.author}}</cite>
<p>{{book.review}}</p>
<!-- Put genre here -->
<book-genres genres="book.genres"></book-genres>
</div>
</li>
</ul>
</div>
Here's a review-form.html
<form name="reviewForm" class="form-horizontal" ng-submit="reviewFormCtrl.addReview(reviewForm)">
<section class="row well live-preview" ng-show="reviewFormCtrl.book.isbn">
<aside class="col-sm-3">
<a href="http://www.amazon.com/gp/product/{{reviewFormCtrl.book.isbn}}">
<img src="http://images.amazon.com/images/P/{{reviewFormCtrl.book.isbn}}.01.ZTZZZZZZ.jpg" alt="Cover of Book" class="full">
</a>
<p>{{reviewFormCtrl.book.rating}}/5</p>
</aside>
<div class="col-sm-9">
<h3>
<a href="http://www.amazon.com/gp/product/{{reviewFormCtrl.book.isbn}}">
{{reviewFormCtrl.book.title}}
</a>
</h3>
<cite class="text-muted">Written by {{reviewFormCtrl.book.author}}</cite>
<p>{{reviewFormCtrl.book.review}}</p>
<book-genres genres="reviewFormCtrl.book.genres"></book-genres>
</div>
</section>
<div class="input-container">
<fieldset class="form-group">
<label for="title" class="col-sm-2 control-label">Title:</label>
<span class="col-sm-9">
<input type="text" class="form-control" id="title"
placeholder="Book Title" ng-model="reviewFormCtrl.book.title">
</span>
</fieldset>
<fieldset class="form-group">
<label for="isbn" class="control-label col-sm-2">ISBN:</label>
<span class="col-sm-9">
<input type="text" id="isbn" class="form-control"
maxLength="10" placeholder="ISBN-10" ng-model="reviewFormCtrl.book.isbn">
</span>
</fieldset>
<fieldset class="form-group">
<label class="control-label col-sm-2" for="author">Author</label>
<span class="col-sm-9">
<input type="text" id="author" class="form-control"
placeholder="Name of the Author" ng-model="reviewFormCtrl.book.author"></span>
</fieldset>
<fieldset class="form-group">
<label class="control-label col-sm-2" for="review">Review</label>
<span class="col-sm-9">
<textarea id="review" class="form-control" cols="30" rows="3"
placeholder="Book Review" ng-model="reviewFormCtrl.book.review"></textarea>
</span>
</fieldset>
<fieldset class="form-group">
<label for="rating" class="control-label col-sm-2">Rating:</label>
<span class="col-sm-9">
<select class="form-control" id="rating" value="5" ng-model="reviewFormCtrl.book.rating">
<option>5</option>
<option>4</option>
<option>3</option>
<option>2</option>
<option>1</option>
</select>
</span>
</fieldset>
<fieldset class="form-group">
<label class="control-label col-sm-2" >Genre:</label>
<div class="genre">
<label for="{{genre}}" class="genre-label form-control" ng-repeat="genre in genres">
<input type="checkbox" name="genre" id="{{genre}}" ng-model="reviewFormCtrl.book.genres[genre]"/>
{{genre}}
</label>
</div>
</fieldset>
<fieldset class="form-group">
<span class="col-sm-9 col-sm-offset-2 button-from-hell">
<button class="btn btn-primary">Save Review</button>
<button class="btn btn-default" ng-click="reviewFormCtrl.showForm = false" style="margin-right: 15px;">Cancel</button>
</span>
</fieldset>
</div>
</form>
You are referencing the reviewFormCtrl outside of the review-form directive on multiple occasions. Both here:
<button class="btn btn-default" ng-click="reviewFormCtrl.showForm = !reviewFormCtrl.showForm" ng-hide="reviewFormCtrl.showForm">{{reviewFormCtrl.showForm ? "Cancel" : "Create a Review"}}</button>
and here:
<hr ng-show="reviewFormCtrl.showForm"/>
You don't have access to it in those places. If you wish to control the directives visibility then perhaps create the showForm property on the readingListCtrl controller instead, double bind it into the directive like so:
<review-form books="readingListCtrl.books" genres="readingListCtrl.genres" visibility="readingListCtrl.showForm"></review-form>
Then add it to the scope property on the directive:
scope: {
books: '=',
genres: '=',
visibility: '='
}
And finally applying it directly to the form element within your template:
<form ng-show="reviewFormCtrl.visibility" name="reviewForm" class="form-horizontal" ng-submit="reviewFormCtrl.addReview(reviewForm)">
And of course updating your Cancel button to change visibility now instead.
I'm trying to apply select2 on a select element within a modal.
The modal is defined as a script ng-template. This works fine if it's not a modal (or a template).
<script type="text/javascript">
$(document).ready(function ($) {
$("#typeDescription").select2({
placeholder: 'Select a type...',
allowClear: true
});
});
</script>
However I cannot include the above code within
<script type="text/ng-template" id="myModal">
</script>
So the thing is I want to apply select2 on my element on the modal. How can I do that? How can I access the modal element by id and apply select2 on it?
EDIT:
I made some changes:
On the controller I made a function:
......
$scope.select = function() {
$(document).ready(function ($) {
$("#typeDescription").select2({
placeholder: 'Select a type...',
allowClear: true
});
});
};
and then within my template:
at the select filed (see bellow) I did like this: data-ng-init="select()"
and actually works, it applies the select2 to my element.
Is this a proper approach? Can I make use of ng-init for this case?
<script type="text/ng-template" id="myModal">
<div class="modal-header">
<button type="button" class="close" ng-click="currentModal.close();" aria-hidden="true">×</button>
<h4 class="modal-title">Title</h4>
</div>
<div class="modal-body">
<div class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label" for="field-1">Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" data-ng-model="newType.Name" id="field-1" placeholder="Name">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="field-5">Description</label>
<div class="col-sm-10">
<textarea class="form-control" data-ng-model="newType.Description" cols="5" id="field-5" placeholder="Description"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="field-5">Select Type</label>
<div class="col-sm-10">
<select class="form-control" id="typeDescription" data-ng-model="newType.Type" data-ng-init="select()">
<option data-ng-repeat="item in allTypes.Types" value="{{item.Value}}">{{item.Text}}</option>
</select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-gray btn-single" data-ng-click="currentModal.close();">Cancel</button>
<button type="button" class="btn btn-info btn-single" data-ng-click="createType(); currentModal.dismiss();">Save</button>
</div>
</script>
I would recommend that you create a directive wrapping the select2 plugin:
var lib = angular.module('lib');
lib.directive('mySelect', [function() {
var link = function (scope, element, attrs) {
element.select2({
placeholder: attrs.placeholder,
allowClear: attrs.allowClear
});
}
return {
restrict: 'A',
link: link
};
}]);
use it like this:
<select data-my-select placeholder="'Select a type...'" allowClear="true"></select>
This will initialize the select2 when the select control is rendered.
I have to show user login page in pop up and have to validate user name and password with the server by using angular js. I create one app model file, and one controller, service and one directive. My code looks like bellow,
app.js
angular.module('mint', ['ngAnimate', 'toastr']);
mycontroller.js
angular.module('mint').controller(
'headercontroller',
[
'$scope',
'headerservice',
'toastr',
function($scope, headerservice, toastr) {
$scope.showModal = false;
$scope.toggleModal = function() {
$scope.showModal = !$scope.showModal;
};
$scope.userSignin = function(){
$scope.userloginbtn = false;
if($scope.signin_form.$valid){ //Error on this line signin_form is undefine. using $valid for undefine
var record = {};
angular.extend(record, $scope.signinForm);
console.log(record);
}else {
$scope.signin_form.submitted = false;
$scope.userloginbtn = true;
}
};
} ]);
my directive.js file is
angular
.module('mint')
.directive(
'modal',
function() {
return {
template : '<div class="modal fade">'
+ '<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"><span><i class="fa fa-user"></i> {{ title }}</span></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;
});
});
}
};
});
My html file looks like
<!DOCTYPE html>
<html lang="en" ng-app="mintmygold">
<body>
<div class="container-fluid ban_bg"
ng-controller="headercontroller">
<div class="but_bg">
<button type="button" class="btn btn-default btn_sin" ng-click="toggleModal()">
<span><i class="fa fa-key"></i> Sign In</span>
</button>
</div>
<modal title="Login" visible="showModal">
<form role="form" name="signin_form" class="signup_form" novalidate
ng-model="signin_form">
<div class="form-group">
<p class="infoMsg" ng-model="signinform_info">Please fill in your login credentials:</p>
</div>
<div class="form-group">
<label for="email">Email address</label>
<input ng-model="signinForm.userEmail" name="userEmail" type="email" class="form-control" id="email" placeholder="Enter email" required />
<div
ng-show="signin_form.$submitted || signin_form.userEmail.$touched">
<span ng-show="signin_form.userEmail.$error.required">Enter your
email.</span> <span ng-show="signin_form.userEmail.$error.email">This
is not a valid email.</span>
</div>
</div>
<div class="form-group">
<label for="password">Password</label>
<input ng-model="signinForm.userPassword" name="userPassword" type="password" class="form-control" id="password" placeholder="Password" required />
<div
ng-show="signin_form.$submitted || signin_form.userPassword.$touched">
<span ng-show="signin_form.userPassword.$error.required">Enter your
password.</span>
</div>
</div>
<button ng-disabled="signin_form.$invalid || !userloginbtn" ng-model="signin" ng-click="userSignin()" type="submit" class="btn btn-primary">Submit</button>
</form>
</modal>
</div></body></html>
Now i can show the popup when click on sign in button. When i submit the form i couldn't get the values of email and password values from the pop up form in controller. what is my mistake of using the scope. Please any one help me.
With a quick overlook, it seems a silly mistake. Change your lines
From
angular.module('mint', ['ngAnimate', 'toastr']);
To
angular.module('mintmygold', ['ngAnimate', 'toastr']);
You are using scope: true which means your directive is creating a child scope and inheriting the properties from its parent.
Therefore any property you define in the directive scope does not exists on you controller scope.
Changing form name=signin_form
for form name=$parent.signin_form or scope: false should fix the problem
I didn't test this though. And it's not a good solution.
I would probably create a service that launches the pop-up and returns a promise that gets resolved/rejected accordingly.
app.js
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope, modal) {
$scope.launch = function(){
modal.show().then(function(user){
console.log(user)
}, function(err){
console.log(err)
});
}
});
app.factory('modal', ["$document", "$compile", "$rootScope", "$templateCache", "$timeout", "$q",
function ($document, $compile, $rootScope, $templateCache, $timeout, $q) {
var $body = $document.find('body');
return {
show: function(){
var defer = $q.defer(),
child = $rootScope.$new();
child.user = {};
child.close = function(){
defer.reject('canceled');
tpl.remove();
}
child.submit = function(){
defer.resolve(child.user);
tpl.remove();
}
var tpl = angular.element($templateCache.get('modal.html'));
$compile(tpl)(child);
$body.append(tpl);
return defer.promise;
}
};
}]);
index.html
<script type="text/ng-template" id="modal.html">
<div class="modal in" style="position: static; display: block">
<div class="modal-dialog">
<form ng-submit="submit()" class="modal-content">
<div class="modal-header">
<button type="button" class="close" ng-click="close()" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
Email: <input ng-model="user.email"></input><br>
Password: <input ng-model="user.password"></input>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" ng-click="close()">Close</button>
<button type="submit" class="btn btn-primary">Sign in</button>
</div>
</form>
</div>
</div>
</script>
<button type="button" ng-click="launch()" class="btn btn-primary">Show modal</button>
Plunker
This is just a proof of concept. I think is enough to get you started. I'd strongly recommend to checkout UI Bootstrap and the way the implement their modal
As a newbie to Angularjs I copied a directive from here: Closing Twitter Bootstrap Modal From Angular Controller, to be able to close a bootstrap modal from a controller, and in my implementation I'm getting an undefined is not a function error. (http://jsfiddle.net/jlamont/7f6dH/6/)
Here's the html
<div ng:app="app">
<div>
<ul><li>Login</li></ul>
<div id='loginModal' class='modal fade' myModal ng-controller="LoginDialogController" tabindex="-2" role="dialog" aria-labelledby="loginModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" ng-click="cancel()">x</button>
<h3>Login MyApp</h3>
</div>
<div class="modal-body">
<form name="login_form">
<alert ng-repeat="alert in alerts" type="danger" close="closeAlert($index)">{{alert.msg}}</alert>
<p><input type="text" class="span3" ng-model="login.user_email" placeholder="Email" required></p>
<p><input type="password" class="span3" ng-model='login.password' placeholder="Password" required></p>
<p><button type="submit" class="btn btn-primary" ng-click="ok()">Sign in</button>
Forgot Password?
</p>
</form>
</div>
<div class="modal-footer">
My.com?
Register
</div>
</div>
</div>
</div>
</div>
</div>
Here's the js
angular.module("app", []).directive('myModal', function() {
return {
restrict: 'A',
scope:{},
link: function(scope, element, attr) {
scope.dismiss = function() {
element.modal('hide');
};
}
}
});
function LoginDialogController($scope){
$scope.ok = function(){
$scope.dismiss();
};
}