Sometimes we need to inject and compile some markup using $compile service from outside AngularJs.
We can do this using the extra injector() added to JQuery/jqLite elements. Like this:
angular.element(document).injector().invoke(function($compile) { var scope = angular.element($div).scope(); $compile($div)(scope); });
And you are receiving an error like- Uncaught Error: [$injector:unpr] http://errors.angularjs.org/undefined/$injector/unpr?xxxx
The reason behind this is that minification changes $compile into random variable that doesn’t tell angular what to inject.
You can avoide this error by declaring your dependencies like this:
angular.element(document).injector().invoke(['$compile', function($compile) { var scope = angular.element($div).scope(); $compile($div)(scope); }]);
That should fix your problem.