所以这是我的代码的片段,这里的目的是根据我的条件隐藏或显示h4元素。
<h4 ng-hide="data_startupcosts.note == ' '">THE COST OF STARTING THIS VENTURE</h4>
<div ng-repeat="data_startupcosts in data.startupcosts track by $index">
{{data_startupcosts.note}}
<ul ng-repeat="data_startupcosts_lists in data_startupcosts.list track by $index">
<li>
我用ng-hide表达但没有运气......任何建议?????
答案 0 :(得分:0)
您使用data_startupcosts
之外的ng-repeat
,因此该变量不存在。而是在ng-repeat
范围内使用它:
<div ng-repeat="data_startupcosts in data.startupcosts track by $index">
<h4 ng-hide="data_startupcosts.note == ' '">THE COST OF STARTING THIS VENTURE</h4>
{{ data_startupcosts.note }}
<ul ng-repeat="data_startupcosts_lists in data_startupcosts.list track by $index">
<li>..</li>
</ul>
</div>
或者,如果你真的想要 div,请使用ng-repeat-start
:
<h4 ng-repeat-start="data_startupcosts in data.startupcosts track by $index"
ng-hide="data_startupcosts.note == ' '">THE COST OF STARTING THIS VENTURE</h4>
<div ng-repeat-end>
{{ data_startupcosts.note }}
<ul ng-repeat="data_startupcosts_lists in data_startupcosts.list track by $index">
<li>..</li>
</ul>
</div>
同时确保您的情况正确,您正在与单个空间进行比较,但是可能没有任何空间? (data_startupcosts.note == ''
)