Angularjs 使用ng repeat显示隐藏的角度
我不熟悉angular,并试图将其纳入我的应用程序中 到目前为止,我已经能够设置一个简单的Angularjs 使用ng repeat显示隐藏的角度,angularjs,angularjs-directive,angularjs-scope,angularjs-ng-repeat,Angularjs,Angularjs Directive,Angularjs Scope,Angularjs Ng Repeat,我不熟悉angular,并试图将其纳入我的应用程序中 到目前为止,我已经能够设置一个简单的ng repeat start/end,它按预期工作 我面临的问题是,当下表中的一列:{{country.detail}}包含大于0的值(例如:“5个可用详细信息”)时,应显示以下行(.countries detail) 如果{country.detail}}包含等于0的值(例如:“0 details available”),则应隐藏以下行(.countries detail) 这是我的HTML: <
ng repeat start/end
,它按预期工作
我面临的问题是,当下表中的一列:{{country.detail}}包含大于0的值(例如:“5个可用详细信息”)时,应显示以下行(.countries detail)
如果{country.detail}}包含等于0的值(例如:“0 details available”),则应隐藏以下行(.countries detail)
这是我的HTML:
<tr ng-repeat-start="country in countries" >
<td data-show="#show-{{$index}}">{{country.name}}</td>
<td>{{country.population}}</td>
<td>{{country.detail}}</td>
<td>{{country.currency}}</td>
<td>{{country.gpd}}</td>
</tr>
<tr ng-repeat-end class="countries-detail" ng-hide="showCountriesDetail">
<td>
<div id="show-{{$index}}">
<p>countries detail lorem epsum</p>
<p>countries detail lorem epsum</p>
<p>countries detail lorem epsum</p>
<p>countries detail lorem epsum</p>
</div>
</td>
</tr>
app.controller("CountriesController", function($scope) {
$scope.showCountriesDetail = true;
});
我应该在控制器中处理此逻辑,还是在指令中处理此逻辑
<tr ng-repeat-start="country in countries" >
<td data-show="#show-{{$index}}">{{country.name}}</td>
<td>{{country.population}}</td>
<td>{{country.detail}}</td>
<td>{{country.currency}}</td>
<td>{{country.gpd}}</td>
</tr>
<tr ng-repeat-end class="countries-detail" ng-if="country.detail[0] > 0">
<td>
<div id="show-{{$index}}">
<p>countries detail lorem epsum</p>
<p>countries detail lorem epsum</p>
<p>countries detail lorem epsum</p>
<p>countries detail lorem epsum</p>
</div>
</td>
</tr>
{{country.name}
{{国家人口}
{{country.detail}
{{国家.货币}
{{country.gpd}
国家详细信息
国家详细信息
国家详细信息
国家详细信息
这对你有用吗?有什么原因不能使用“country.detail@GruffBunny”这个表达吗?我该把它放在哪里?此外,country.detail中的字符串包含“5个可用的详细信息”@OamPsy Gruff Bunny表示要将不平等等式直接放入ng hide指令中。例如:
ng hide=“country.detail@m.e.conroy-谢谢你……但我要说的是,country.detail不只是显示一个数字,例如5……但是这个字符串“5 details available”…@OamPsy使用包含详细信息的数组的长度。ng hide=“country.detaillist.length”