jameskleeh / angular-confirm

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

When uglyfied : Unknown provider: eProvider <- e <- $confirm <- #57

Closed atais closed 8 years ago

atais commented 8 years ago

Hello!

So I have found a small issue in your library. I build my application using normal sources and minify/uglyfy it all together with my app.

After minification I encountered error described here: https://docs.angularjs.org/error/$injector/unpr?p0=eProvider%20%3C-%20e%20%3C-%20$confirm%20%3C-

A quick googling gave me this hint: http://stackoverflow.com/questions/13459452/rails-3-angularjs-minification-does-not-work-in-production-unknown-provider

And so I have found in your code the missing parts:

.controller('ConfirmModalController', function ($scope, $uibModalInstance, data) {
(...)
.factory('$confirm', function ($uibModal, $confirmModalDefaults) {
(...)
.directive('confirm', function ($confirm, $timeout) {

they should look like this:

.controller('ConfirmModalController', ['$scope', '$uibModalInstance', 'data', function ($scope, $uibModalInstance, data) {
(...)
.factory('$confirm', ['$uibModal', '$confirmModalDefaults', function ($uibModal, $confirmModalDefaults) {
(...)
.directive('confirm', ['$confirm', '$timeout', function ($confirm, $timeout) {

But later I noticed you are using ngAnnotate = require('gulp-ng-annotate'), in your build script.

However if you want it to work properly you need to follow this guidelines: https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#minification-and-annotation

I can fix it and present a pull-request if you prefer.

jameskleeh commented 8 years ago

You need to follow the guidelines and use ngAnnotate or use the minified version.

atais commented 8 years ago

I forgot that you build script does not affect my files, so yes your minification works OK.

However, I think its a matter of "good practice" that you should provide the lib that could be easily minified. All other libraries worked that way. And I noticed I was not the first one to encounter this issue.

raoel commented 8 years ago

Version 1.2.4

I have a build script with gulp-ng-annotate, however I think I am getting the same error.

[$injector:unpr] Unknown provider: tProvider <- t <- confirmDirective