gpt4 book ai didi

javascript - Angular 过滤

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:43:01 26 4
gpt4 key购买 nike

我有一个表格,分为如下几个部分:

education: {faculty: "", high_school: ""}
experience: {experience_1: "", experience_2: "", experience_3: ""}
personalInfo: {id: "", type: "", email: "", password: "", password_new: "", first_name: "", last_name: "",…}
skills: {skill_1: "", skill_2: ""}

所有输入都使用 ngRepeat 显示。

 <div ng-repeat="(key, val) in user" >
<div ng-repeat="(k,v) in val | filter:filterBySection" class="formParameter" >

<span class="param_label">
{{k}}:
</span>

<span e-class="form-control " class="formParameterValue" editable-text="user.{{key}}.{{k}}" e-name="{{k}}">{{v}}</span>
</div>
</div>

我将如何实现一个只显示所选部分的过滤器。例如:如果我按下教育按钮,则只显示“教职工”和“高中”

<li ng-repeat="(a,b) in user" ng-click="filterBySection = ?:{{a}}" ng-model="filterBySection"><a href="#">{{doc_param}}</a></li>

请提出建议。

最佳答案

您可以通过使用按钮设置特定变量来显示不同的 div 容器,在本例中为“tab”。然后,通过使用 ng-show 测试“tab”的值,只会显示具有相应 tab-value 的 dif。

// Links or buttons
<a href ng-click="tab = 1"> Description</a>
<a href ng-click="tab = 2"> Specifications</a>

// DIVS
<div class ="panel" ng-show="tab === 1">
<h4>Description</h4>
<p>{{product.description}}</p>
</div>
<div class ="panel" ng-show="tab === 2">
<h4>Specifications</h4>
<p>{{product.specification}}</p>
</div>

关于javascript - Angular 过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30731695/

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