2017-04-10 19 views
0

NG-顯示不評估$ scope.foo.name動態添加HTML!== '根' 在控制器動態添加HTML

var button = d3.select("#someId") 
       .append("button") 
       .attr("class", "button") 
       .attr("ng-show","$scope.foo.name !== 'root'") 
       .html('{{$scope.foo.name}}').on("click", function(){ 
        up($scope.foo);; 

     }) .call(function() { 
       //$compile(this[0][0].parentElement)($scope); 
       $compile(angular.element(this[0][0].parentElement))($scope); 

      }); 
+2

您在'.attr( 「類」,「按鈕)'錯過了右引號。 –

回答

1

你不需要在你的模板中使用$scope

.attr("ng-show","foo.name !== 'root'") 
.html('{{foo.name}}')