親の選択に依存する ui-select2 ドロップダウンがあります。最初の ui-select2 のオプションの配列があり、そのドロップダウンから何かが選択されると、次のドロップダウンが表示されます。2 番目のドロップダウンで使用できるオプションは、最初のドロップダウンで選択した内容によって異なります。ng-repeat ディレクティブは、選択肢の配列を反復しています。ここにhtmlとjsコードがあります。
HTML:
<select name="application" placeholder="Select a Tenant"
ng-disabled="!sharedObj.tenantApplications ||
sharedObj.tenantApplications.length == null"
class="form-control" id="application"
ng-change="vmOrderItem.vmNameUSI=null" ui-select2
ng-model="vmOrderItem.tenantApplication" title="Select tenant application"
data-style="btn-default" required><option></option>
<option ng-repeat="tenantApplication in sharedObj.tenantApplications |
filter:tenantFilter()" value="{{tenantApplication.id}}">{{tenantApplication.name}}
</option>
</select>
JS:
/** Filters the tenant depending on what domain is selected */
$scope.tenantFilter = function(tenantApplication) {
$scope.sharedObj.tenantApplications;
tenantApplication.name;
tenantApplication.id;
return true;
/* return $scope.vmOrderItem.domain.id == tenantApplication.domainId;*/
}
問題は、true を返しても、ドロップダウンに何も表示されないことです。ロジックをテストするためにこれを行いました。関数で tenantApplication パラメーターが常に未定義である理由がわかりません。google chrome inspect 要素を使用してブレークポイントを挿入しましたが、引数が未定義であると不平を言います。しかし、true を返すと正しく動作しない理由がわかりません。私は JavaScript と AngularJS の初心者なので、どんな助けでも大歓迎です。私はすべての AngularJS の例に取り組み、ドキュメントを読みましたが、まだ初心者です。