AngularJS中的级联选择/下拉列表

时间:2015-07-01 14:39:05

标签: javascript json angularjs select ng-options

这是一个重复的问题,但在阅读了几个好的答案之后,我无法让我的级联下拉工作。两个下拉列表都在工作,但是当我尝试过滤第二个时,我无法做到。

<div class="col-md-8">
         <select class="form-control" ng-model="selectedReason" ng-options="reason.returnreasonId as reason.returnText for reason in returnreasons">
         </select>
         <select class="form-control" ng-model="selectedDefectdesc" ng-options="defectdesc.defectdescId as defectdesc.text for defectdesc in defectDescs  | filter:{returnreasonReturnreasonId.returnreasonId: selectedReason.returnreasonId }">
         </select>

</div>

returnReason JSON

<returnreasons>
    <returnreason>
    <languageLanguageId>
     <languageId>1</languageId>
       <lastUpdate>2015-05-19T16:51:11+03:00</lastUpdate>
       <name>svenska</name>
     </languageLanguageId>
     <returnText>Product is broken</returnText>
     <returnreasonId>1</returnreasonId>
   </returnreason>
   <returnreason>
     <languageLanguageId>
       <languageId>2</languageId>
       <lastUpdate>2015-05-19T16:51:11+03:00</lastUpdate>
       <name>english</name>
     </languageLanguageId>
    <returnText>VISUAL FAULT IN THE PRODUCT</returnText>
    <returnreasonId>2</returnreasonId>
  </returnreason>
  <returnreason>
     <languageLanguageId>
       <languageId>3</languageId>
       <lastUpdate>2015-05-19T16:51:11+03:00</lastUpdate>
       <name>suomi</name>
     </languageLanguageId>
  <returnText>HUOLLON TARVE TAI LISÄTYÖ</returnText>
  <returnreasonId>3</returnreasonId>
  </returnreason>
</returnreasons>

defectDesc json

<defectdescs>
  <defectdesc>
    <brandtype>0</brandtype>
    <defectdescId>1</defectdescId>
    <languageLanguageId>...</languageLanguageId>
      <lastUpdated>2015-07-01T16:04:19+03:00</lastUpdated>
  <returnreasonReturnreasonId>
    <languageLanguageId>...</languageLanguageId>
    <returnText>VISUAL FAULT IN THE PRODUCT</returnText>
    <returnreasonId>2</returnreasonId>
  </returnreasonReturnreasonId>
  <text>painting</text>
</defectdesc>
<defectdesc>
  <brandtype>0</brandtype>
  <defectdescId>2</defectdescId>
  <languageLanguageId>
    <languageId>1</languageId>
    <lastUpdate>2015-05-19T16:51:11+03:00</lastUpdate>
   <name>svenska</name>
  </languageLanguageId>
  <lastUpdated>2015-07-01T16:11:17+03:00</lastUpdated>
  <returnreasonReturnreasonId>
    <languageLanguageId>
      <languageId>1</languageId>
      <lastUpdate>2015-05-19T16:51:11+03:00</lastUpdate>
      <name>suomi</name>
    </languageLanguageId>
  <returnText>HUOLLON TARVE TAI LISÄTYÖ</returnText>
  <returnreasonId>3</returnreasonId>
  </returnreasonReturnreasonId>
  <text>something something</text>
</defectdesc>
...

控制器

//Fetching reasons
$scope.returnreasons = returnReasonSvc.query();

//Fetching all defect descriptions
$scope.defectDescs = defectDescSvc.query();

0 个答案:

没有答案