Reputation: 7701
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.
Upvotes: 2
Views: 1187
Reputation: 17064
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);
}]);
Upvotes: 6