我想知道如何在代码中使用链式过滤器

时间:2018-11-23 22:04:01

标签: angularjs-directive

这是一个JSON格式的示例,其中我使用的是基于相关问题的过滤器。

请告诉我如何获取组件数组?

除最后一个过滤器外,其他所有功能都正常运行。

$scope.items = [
        {
            family: "external_ip",
            releases: [
                            {
                                release: "eip_operations",
                                components: ["ip.disclourse", "ip.irr"]

                             },
                            {
                                release: "eip_purchase",
                                components: ["ip.hard", "ip.soft"]

                            }

                    ]
        },**strong text**
        {
            family: "eda_licensing",
            releases: [
                                {
                                    release: "elm",
                                    components: ["service.licnse_elm"]

                                },
                                {
                                    release: "denial",
                                    components: ["service.license_denial"]

                                }

                     ]
         }

    ];

这是视图   

                     <div  style="margin-right: 10px">
                         <div>
                             <label>Family</label>
                         </div>
                         <div class="form-group">
                             <div>
                                 <select id="selectjs" class="form-control" ng-model="selectedFamily" ng-options="item.family as item.family for item in items">
                                     <option value="">Select a family</option>
                                 </select>

                             </div>
                         </div>
                     </div>

                     <div  >
                         <div>

                             <label>Release</label>
                         </div>
                         <div class="form-group">
                             <select class="form-control" id="Select1" ng-model="selectedRelease"  ng-disabled="!selectedFamily" ng-options="r.release as r.release for r in ((items | filter:{family:selectedFamily})[0].releases)">
                                 <option value="">Select a release</option>
                             </select>
                         </div>
                     </div>

                     <div >

                         <div>

                             <label>Component</label>
                         </div>
                         <div class="form-group">

                             <select class="form-control" id="year" ng-model="selectedComponent" ng-disabled="!selectedRelease" ng-options="component as component for component in ((items | filter:{family:selectedFamily}| filter:{releases:selectedRelease})[0].components)">
                                 <option value="">Select a component</option>
                             </select>
                         </div>
                     </div>
                     <div>
                         <div>
                             <label>Priority</label>
                         </div>
                         <div class="form-group">
                             <select class="form-control" id="quarter" ng-model="selectedPriority">
                                 <option>All</option>
                                 <option>1-showstopper</option>
                                 <option>2-high</option>
                                 <option>3-medium</option>
                                 <option>4-low</option>
                             </select>
                         </div>
                     </div>

                     <div>

                         <div>
                             <br />
                             <button type="submit" class="btn btn-info center-block" id="filterBtn" style="float: left;">Apply Filter</button>
                         </div>
                     </div>


                 <!-- <div class="row">
             <div class="col-lg-12">
                 <p class="pull-right">

                     <button type="submit" class="btn btn-info btn-block" id="filterBtn">Apply Filter</button>
                 </p>
             </div>
         </div> -->
             </form>

我想在selectedComponent中检索组件。

0 个答案:

没有答案