gpt4 book ai didi

javascript - 如何在angular js中应用ng-if

转载 作者:行者123 更新时间:2023-11-30 11:53:56 25 4
gpt4 key购买 nike

我正在从表单中的服务中检索数据。

[["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>

最佳答案

你可以这样做:

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>

关于javascript - 如何在angular js中应用ng-if,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38637299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com