javascript - Angular ng-if in compile doesn't respond -


I am trying to create an element with an angular element and add some elements. An NG in the new element - if it is necessary to show whether it is visible on a scope variable condition. But for some reason this does not answer the change. This code is:

  return {restrict: 'a', scope: {object: '= on}}, compiled: function (amm) {var td = angular.element (' & Lt; td> & lt; / td & gt; '), passro = angular. Element ('& lt; i class = "FA-Arrow-circle-right" NG-if = "! Object.open">  gt;'), Opener = angular Element ('& lt; i class = "fa-arrow-circle-down" ng-if = "object. Open"> gt; ;); Td.append (closeRow) .append (openRow); Elem.append (TD); Return link; }} Function link ($ radius, AMM) {$ scope.object.open = false; Elem.on ("click", function () {$ scope. $ Apply (function () {$ scope.object.open =! $ Scope.object.open;})}}}}  

}

and html:

  & lt; tr on the slide-to-line = "post"> gt; & lt; td & gt; {{Post.title}} & lt; / Td & gt; & lt; TD & gt; {{post.text}} & lt; / TD & gt; & lt; / tr & gt; & lt; tr & You should not use the compile function for this. Link function + $ Try using the blanket service, so that the injection HTM is correctly scanned by the scope Junk can be tilted with:  
  return {restrict: 'a', scope: {object: '= on}}, link: function (scope, amm) {var td = angular .element ('& lt; td & gt; & lt; / td & gt;'), closeRow = angular.element ('& lt; i square =' fa-arrow-circle-right "ng -if ="! Object.open "> gt; & lt; / i & gt; '), openRow = angular.element (' & lt; i class =" FA FA-Arrow-Circle-Down "ng-if =" Object.Open " & Gt; & Lt; / I & gt; '); Td.append (closeRow) .append (openRow); $ Collection (TD) (scope); Elem.append (TD); Scope.object.open = false; Elem.on ("click", function () {apply scope. $ (Function () {scope.object.open =! Scope.object.open;})}}}}}  

Demo:


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -