2

On my development machine I don't have a problem. However when I load the same form up on my production server I get error Uncaught Error: [$injector:unpr] Unknown provider: aProvider <- a

If i remove the following code it will work fine in my production server.

$scope.grid = function(targetElement) {
    var $div = $('<div style="height:375px; top:-1%; position: absolute; width:100%; " ><div reports  data-uri="repouri" data-form-data="formData"   data-show-filter="false" data-field="[]" ></div></div>');
    targetElement.append($div);

    angular.element(targetElement).injector().invoke(function($compile) {
        var scope = angular.element($div).scope();
        $compile($div)(scope);
    });
};

Is there any solution to fix this problem. Thanks in advance.

1
  • This is wiring up what I assume is a directive, please paste the code for the directive reports May 26, 2015 at 11:25

1 Answer 1

6

You have an error on production because over there your code is minified, hence $compile is named differently thus hurting the dependency injection mechanism of Angular.

You need to do this to resolve:

angular.element(targetElement).injector().invoke(['$compile', function($compile) {
    var scope = angular.element($div).scope();
    $compile($div)(scope);
}]);
1
  • Wow, minification in production and not in dev environment, well spotted. May 26, 2015 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.