jameskleeh / angular-confirm

Confirmation modal dialog for AngularJS
Apache License 2.0
150 stars 75 forks source link

Add dependency injection #51

Closed vbyno closed 8 years ago

vbyno commented 8 years ago

Guys, I had problems using { strictDi: true } so I added dependency injection to functions. Also I had errors as far as there were no template files. So I required whole 'ui.bootstrap' module instead of just ui.bootstrap.modal. (as was advised here. Suggestions are welcomed. Hope you'll find these changes valuable

simison commented 8 years ago

Hmm, interesting dilemma. I was also considering turning strictDi: true for @Trustroots.

So I required whole 'ui.bootstrap' module instead of just ui.bootstrap.modal

This wouldn't work in my case, since I'm custom-building ui.bootstrap to avoid having so much not-needed JS. It should work if you also inject template modules, right?

vbyno commented 8 years ago

@simison

It should work if you also inject template modules, right?

Yep, it works after adding angular.module('angular-confirm', ['ui.bootstrap.modal', 'uib/template/modal/window.html', 'uib/template/modal/backdrop.html']) to this line Would that implementation be more appropriate?

vbyno commented 8 years ago

So, I left it as it was with ui.bootstrap.modaland just added dependency injection. Now it should just fix this issue

jameskleeh commented 8 years ago

The injection stuff happens automatically when creating the minified version. If you don't have a process in place for that to happen with your build, I recommend using the minified version.

.controller("ConfirmModalController",["$scope","$uibModalInstance","data",function(e,t,i)

vbyno commented 8 years ago

I wouldn't agree with that. Minified version is bad for debugging in development mode. Even ui-bootstrap which you use adds injection to the main version not only for minified.

jameskleeh commented 8 years ago

@vbyno I would recommend adding an ng-annotate step to your build so you can have the best of both worlds.