javascript - ng-show 不评估 $scope.foo.name !== 'root' 在 Controller 中动态添加 html

标签 javascript angularjs ng-show

ng-show 不评估 $scope.foo.name !== 'root' 在 Controller 中动态添加 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);

            });

最佳答案

您不需要在模板中使用$scope:

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

关于javascript - ng-show 不评估 $scope.foo.name !== 'root' 在 Controller 中动态添加 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43334628/

相关文章:

javascript - 如何使用 sitemap.js?

javascript - Three.js 中的头部耦合/离轴透视

javascript - Protractor Jasmine 描述嵌套在 it block 中的 block

javascript - ng-show之后如何执行函数?

javascript - Flow 无法理解对 null 或未定义的检查

javascript - 如何在数据库和 Firebase 身份验证系统之间链接数据

javascript - MEANJS 用户配置文件功能

javascript - 如果在过滤器中返回空值,如何显示 'No Books Found' 行?

javascript - 基于字符串数组的 AngularJS 过滤器?

javascript - 你如何使用 HTML/JS 在 chrome 中打开一个新选项卡?