The DOM is mostly manipulated in Angularjs, and now encounters a special case where the DOM is not available in one instruction:
var directivectrl=angular.module ("Directivectrl", []);d Irectivectrl.controller ("Ctrltwo", [' $scope ', function ($ Scope) {$scope. Name= "Me";}]); Directivectrl.directive ("num", function () {return{restrict: ' E ', Template: ' <div ng-repeat= "I in [+]" Ng-controller= "Ctrltwo" >{{name}}</div> ", Replace:true,link:function (scope,ele,attr) {console.log (ele);} };});
The output is [comment] instead of [div.ng-scope.ng-binding], so the DOM element cannot be manipulated.
My solution is to:
Ng-repeat= "I in [+]"
On the outer label of the NUM tag, everything is fine, of course it just avoids the problem. If one day I know the problem, I will follow up with another article as a supplement.
This article is from the "11416117" blog, please be sure to keep this source http://11426117.blog.51cto.com/11416117/1760873
The link method does not get the element correctly in the ANGULARJS directive