0

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?

3
  • What are the libraries do you included in HTML view? Can you share it here? Commented Oct 7, 2016 at 5:20
  • I am using dhx schedule. So I add ng-modal when displays a newEvent dialog. Commented Oct 7, 2016 at 5:24
  • Try to change with angular version Commented Oct 7, 2016 at 5:28

1 Answer 1

1

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...)

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much. I followed your guide and fixed it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.