网络服务返回值...如果返回的值是==' 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;
}
};
};
});
答案 0 :(得分:4)
使用{{}}
或ng-hide
时,您不需要ng-show
。
template: '<img ng-hide="showStar(value)"/>'
应该可以正常使用