Angularjs 如何在customdirective中比较ng show中的stringvalue?

Angularjs 如何在customdirective中比较ng show中的stringvalue?,angularjs,angularjs-directive,angularjs-ng-repeat,Angularjs,Angularjs Directive,Angularjs Ng Repeat,尝试使用包含ng show语句的指令。基本上,它检查字符串的值,该字符串是my'names'jsonarray中的status_p1属性: ng-show="name.status_p1==working" 该指令的定义如下: app.directive('radioButton',function(){ return { restrict: 'E', replace: 'true', template: '<table border="2px">'

尝试使用包含ng show语句的指令。基本上,它检查字符串的值,该字符串是my'names'jsonarray中的status_p1属性:

ng-show="name.status_p1==working"
该指令的定义如下:

app.directive('radioButton',function(){
  return {
    restrict: 'E',

    replace: 'true',

    template: '<table border="2px">' +
    '<tr><td>{{name.name}}</td><td>Working</td><td><img src="http://www.iconshock.com/img_jpg/REALVISTA/general/jpg/256/cross_icon.jpg" alt="img1" id="imgworking" ng-show="name.status_p1!=working"><img src="http://png-1.findicons.com/files/icons/2198/dark_glass/128/camera_test.png" alt="img2" ng-show="name.status_p1==working"></td></tr>' +
    '</table>'
  };
})
最后是主页:

<body ng-controller="MainCtrl">
    <div ng-repeat="name in names">
      <radio-button></radio-button>
    </div>
</body>

当前显示的是一个叉号,它应该在该叉号上显示一个勾号。我希望条件的计算结果为TRUE,因为status_p1属性等于'working'。如何修改此showng语句以使字符串比较正常工作? plunkr链接:

表达式

ng-show="name.status_p1==working"
name.status\u p1
与当前作用域中未定义的
working
属性进行比较。您需要将它与文本字符串
“working”
进行比较

ng-show="name.status_p1=='working'";

修改

在我的情况下,我有:

ng-show ="authenticated == {{it.logged_in_view}} || {{it.logged_in_view == 'neutral'}}"
不得不改成这样:

ng-show ='authenticated == {{it.logged_in_view}} || {{it.logged_in_view == "neutral"}}'

我将属性字符串用单引号括起来,将要比较的字符串用双引号括起来。

由于模板字符串由单引号分隔,因此需要对
\'working\\
周围的单引号进行转义。检查修改后的PRUNKR。
ng-show ='authenticated == {{it.logged_in_view}} || {{it.logged_in_view == "neutral"}}'