Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit 58cc8f6

Browse files
committed
Merge pull request #158 from venil7/controller-as
Added controller as syntax
2 parents 3dfa758 + 6b67da4 commit 58cc8f6

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ app.controller("MyCtrl", function(dialogs){
2828

2929
```dialogs.notify('Something Happened','Something happened at this point in the application that I wish to let you know about');```
3030

31-
```dialogs.create('url/to/a/template','ctrlrToUse',{data: topass,anotherVar: 'value'},{});```
31+
```dialogs.create('url/to/a/template','ctrlrToUse',{data: topass,anotherVar: 'value'},{},'ctrl');```
3232

3333
### API
3434

@@ -61,14 +61,15 @@ All Dialogs return a object with property `result` which is a promise `OK/Yes` r
6161

6262
#### dialogs.create
6363

64-
```dialogs.create(url, ctrlr, data, opts)```
64+
```dialogs.create(url, ctrlr, data, opts, ctrlAs)```
6565

6666
| Name | Type | Description |
6767
|---|---|---|
6868
| url | `string` | Template Url |
6969
| ctrlr | `string` | Dialog Controller |
7070
| data | `object` | data available as a "data" service in the controller |
7171
| opts | `object<IDialogOptions>` | Options for the dialog with the addition of `copy: false|true` which will copy the data instead of passing reference |
72+
| ctrlAs | `string` | `controllerAs` reference
7273

7374
#### IDialogOptions Properties
7475

src/dialogs-services.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers'])
2828

2929
/**
3030
* Use Backdrop
31-
*
31+
*
3232
* Sets the use of the modal backdrop. Either to have one or not and
33-
* whether or not it responds to mouse clicks ('static' sets the
33+
* whether or not it responds to mouse clicks ('static' sets the
3434
* backdrop to true and does not respond to mouse clicks).
3535
*
3636
* @param val mixed (true, false, 'static')
@@ -42,7 +42,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers'])
4242

4343
/**
4444
* Use ESC Close
45-
*
45+
*
4646
* Sets the use of the ESC (escape) key to close modal windows.
4747
*
4848
* @param val boolean
@@ -66,7 +66,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers'])
6666

6767
/**
6868
* Use Copy
69-
*
69+
*
7070
* Determines the use of angular.copy when sending data to the modal controller.
7171
*
7272
* @param val boolean
@@ -91,7 +91,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers'])
9191
/**
9292
* Set Size
9393
*
94-
* Sets the modal size to use (sm,lg,md), requires Angular-ui-Bootstrap 0.11.0 and Bootstrap 3.1.0 +
94+
* Sets the modal size to use (sm,lg,md), requires Angular-ui-Bootstrap 0.11.0 and Bootstrap 3.1.0 +
9595
*
9696
* @param val string (sm,lg,md)
9797
*/
@@ -121,7 +121,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers'])
121121

122122

123123
this.$get = ['$uibModal',function ($uibModal){
124-
124+
125125
return {
126126
/**
127127
* Error Dialog
@@ -153,7 +153,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers'])
153153
}
154154
}); // end modal.open
155155
}, // end error
156-
156+
157157
/**
158158
* Wait Dialog
159159
*
@@ -186,7 +186,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers'])
186186
}
187187
}); // end modal.open
188188
}, // end wait
189-
189+
190190
/**
191191
* Notify Dialog
192192
*
@@ -217,7 +217,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers'])
217217
}
218218
}); // end modal.open
219219
}, // end notify
220-
220+
221221
/**
222222
* Confirm Dialog
223223
*
@@ -248,7 +248,7 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers'])
248248
}
249249
}); // end modal.open
250250
}, // end confirm
251-
251+
252252
/**
253253
* Create Custom Dialog
254254
*
@@ -257,21 +257,22 @@ angular.module('dialogs.services',['ui.bootstrap.modal','dialogs.controllers'])
257257
* @param data object
258258
* @param opts object
259259
*/
260-
create : function(url,ctrlr,data,opts){
260+
create : function(url,ctrlr,data,opts,ctrlAs){
261261
var copy = (opts && angular.isDefined(opts.copy)) ? opts.copy : _copy;
262262
opts = _setOpts(opts);
263263

264264
return $uibModal.open({
265265
templateUrl : url,
266266
controller : ctrlr,
267+
controllerAs : ctrlAs,
267268
keyboard : opts.kb,
268269
backdrop : opts.bd,
269270
backdropClass: opts.bdc,
270271
windowClass: opts.wc,
271272
size: opts.ws,
272273
animation: opts.anim,
273274
resolve : {
274-
data : function() {
275+
data : function() {
275276
if(copy)
276277
return angular.copy(data);
277278
else

0 commit comments

Comments
 (0)