4
我有一組select-dropdown菜單,我試圖根據angularJS中第一個select-dropdown的選擇填充第二個select-dropdown。我不知道如何從這開始。AnglularJS:基於第一個select-dropdown的選擇填充第二個select-dropdown
我已準備好所有模型,但我正在與動態人口掙扎。
選擇1:
<select ng-model="selectedSource" ng-options="source.name for source in sourceList">
<option value="">-- Select item --</option>
</select>
$scope.sourceList= [
{
"name":"Person",
"has": ["a","b","c"]
},
{
"name":"Car",
"has": ["1","2","3"]
}
];
什麼想實現:
當sourceList.name
是Person
填入第2個選擇,下拉與targerSet1
$scope.targerSet1= [
{
"name":"King Julien"
}
];
當sourceList.name
我小號Car
填入第二個選擇,下拉與targerSet2
$scope.targerSet2= [
{
"name":"RoyalMobile"
}
];
[可能的重複](http://stackoverflow.com/questions/16191060/filter-dropdown-with-subcategories-in-angular)。 –
我知道它可能是重複的..但那個並沒有真正的幫助。 –
One controller,two models is the way to go https://stackoverflow.com/questions/18345020/populate-dropdown-2-based-on-dropdown-1-selection – AskPete