Reputation: 1222
Here is unbundled angular code which is working well.
angular.module('XXX').directive('xxx', ['$compile', '$injector', function($compile, $injector){
return {
restrict: 'A',
scope: false,
transclude: true,
...
XXX.attachEvent("XXX", function(id){
angular.element(document.querySelector( '[name="isallday"]' )).attr('ng-model', 'isallday');
angular.element( document.querySelector( ".dhx_section_time" )
.getElementsByTagName("select") ).attr('ng-class', '{dhx_time_disable: isallday}').attr('ng-disabled', 'isallday');
var el = angular.element(document.querySelector( ".dhx_cal_larea" ));
$injector = el.injector();
$injector.invoke(function($compile){
$compile(el)($scope)
})
})
}
}]);
I added ng-model dynamically not statically. But when I run this code in bundled environment, it displays an error.
uncaught Error: [$injector:unpr] http://errors.angularjs.org/1.4.1/$injector/unpr?p0=tProvider%203C-%20t
My project use asp.net and angularjs and dhx. How can I fix this error?
Upvotes: 0
Views: 160
Reputation: 7820
Your issue probably is minification/uglification among these lines:
$injector.invoke(function($compile){
$compile(el)($scope)
})
When the invoked function gets minified/uglified, its first parameter $compile
is renamed to t
in your case resulting in the unknown tProvider
error. Try the following:
$injector.invoke(['$compile', function($compile){
$compile(el)($scope)
}])
(or reuse the $compile
you injected in your directive...)
Upvotes: 1