Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 值为false时在ng bind html上显示图标_Javascript_Angularjs_Font Awesome_Ui Select_Ng Bind Html - Fatal编程技术网

Javascript 值为false时在ng bind html上显示图标

Javascript 值为false时在ng bind html上显示图标,javascript,angularjs,font-awesome,ui-select,ng-bind-html,Javascript,Angularjs,Font Awesome,Ui Select,Ng Bind Html,我需要根据布尔值在ui select上的ng bind html中显示一个图标 <span ng-bind-html="project.IsActive == false && <i class="fa fa-ban" aria-hidden="true"></i> | highlight: $select.search"></span> 当然,这段代码不起作用,它只是解释我需要什么,关于如何做有什么想法吗?Ng bind

我需要根据布尔值在ui select上的ng bind html中显示一个图标

<span  ng-bind-html="project.IsActive == false && <i class="fa fa-ban" aria-hidden="true"></i> | highlight: $select.search"></span>


当然,这段代码不起作用,它只是解释我需要什么,关于如何做有什么想法吗?

Ng bind html
是一个指令,应该将受信任的html作为参数。因此,您应该使用wether移动您的逻辑,以向控制器显示您的图标,并使您的html受到angulars
$sce
服务的信任:

let icon = $sce.trustAsHtml('<i class="fa fa-ban" aria-hidden="true"></i>');
$scope.html = !IsActive ? icon : null;
let icon=$sce.trustAsHtml(“”);
$scope.html=!我很活跃?图标:空;
然后在视图中,你会这样:

<span ng-bind-html="html"></span>

angular所做的所有这些都是为了防止不安全的资源或某些XS被注入到您的应用程序中

查这个