0

网络服务返回值......如果返回的值是 == 'N' 我想隐藏 html 元素。我的问题是我无法让 ng-hide 和 ng-show 在模板中工作。我查看了其他类似的问题,但修复对我不起作用。令人困惑的部分是,如果我查看呈现的页面,ng-show 语句看起来是正确的。

这是我的 HTML:

<span five-star-img value="appHeader.star1"></span>
<span five-star-img value="appHeader.star2"></span>

这是我的指令:

angular.module('myApp')
.directive('fiveStarImg', function() {
    return {
       template: '<img ng-hide="{{showStar(value)}}"/>',
        restrict: 'A',
        replace: true,
        scope: {
            value: '=',
            isize: '@'
        };                  


        scope.showStar = function(value) {
            if (value == 'N') {
               return true;
            } else {
               return false;
            }
        };
    };
 });
4

1 回答 1

4

{{}}使用时不需要ng-hideng-show

template: '<img ng-hide="showStar(value)"/>'应该可以正常工作

于 2014-06-13T19:57:51.337 回答