网络服务返回值......如果返回的值是 == '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;
}
};
};
});