我正在从表单中的服务检索数据。
[["Sql Injection",0],["Proxy Abuse",0],["Spam",0],["Information and Source Code Leakage",0],["System Command Injection",0],["Cross-Site Request Forgery",0],["Session Hijacking",0],["PHP Injection",0],["Request Anomaly",0],["Local/Remote File Inclusion",0],["Cross-Site Scripting",0]].现在,我希望如果每种攻击类型的计数为零,则不显示任何内容。我如何通过ng-if来处理这个问题。模板代码:
<div class="col-md-6 b-r b-light no-border-xs" ng-show="webSummary[0]">
<highchart id="chart1" config="webConfig" class="span9" ></highchart>
</div>发布于 2016-07-28 21:20:21
您可以执行以下操作:
angular
.module('MyApp', [])
.controller('MyController', function($scope) {
$scope.webSummary = [["Sql Injection",0],["Proxy Abuse",0],["Spam",0],["Information and Source Code Leakage",0],["System Command Injection",0],["Cross-Site Request Forgery",0],["Session Hijacking",0],["PHP Injection",0],["Request Anomaly",0],["Local/Remote File Inclusion",0],["Cross-Site Scripting",0]];
});<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="MyApp" ng-controller="MyController">
<div class="col-md-6 b-r b-light no-border-xs"
ng-repeat="ws in webSummary"
ng-if="ws[1]">
<highchart id="chart1" config="webConfig" class="span9"></highchart>
</div>
</div>
发布于 2016-07-28 21:22:20
你可以做到
<div class="col-md-6 b-r b-light no-border-xs" ng-if="checkAttackCount()">
<highchart id="chart1" config="webConfig" class="span9" ></highchart>
</div>在控制器中
function checkAttackCount(){
for(var i=0;i<webSummary.length;i++){
if(webSummary[i][1]>0){
return true;
}
}
return false;
}https://stackoverflow.com/questions/38637299
复制相似问题