我想引用ng-repeat
中的選定項目,然後使用該值確定是否會通過ng-show
顯示另一個下拉菜單。帶有角度的無源下拉菜單
我特別想使用階段值來影響hq是否會顯示在頁面上。讓我知道是否需要澄清任何事情。
這裏是我的代碼:
<div ng-app="erasmus">
<div class="col-sm-4">
<div ng-controller="erasmusController">
<center><h2>Phase:</h2></center>
<center><select id="phase" name="phase">
<option ng-repeat="x in phase track by $index">{{x}}
</select></center>
</div>
</div>
<div class="col-sm-4">
<div ng-controller="erasmusController">
<center><h2>Side:</h2></center>
<center><select id="side" name="side">
<option ng-repeat="x in side">{{x}}
</select></center>
</div>
</div>
<div class="col-sm-4">
<div ng-controller="erasmusController">
<div ng-show="showHQ">
<center><h2 id="hq">Is HQs OOS?:</h2></center>
<center><select id="hq" name="hq">
<option ng-repeat="x in hq">{{x}}
</select></center>
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<input type="submit">
</div>
</form>
</div>
</body>
<script>
var app = angular.module("erasmus",[]);
app.controller("erasmusController",function($scope){
$scope.phase = ["Beggining","Middle","End"];
$scope.side = ["Japanese","Allied"];
$scope.showHQ = false;
$scope.hq = ["Yes","No"];
});
數組必須具有「value:」而不是value =? –
此外,我如何從sideVal獲得值,當我嘗試該功能時似乎不起作用。 –
看我的更新/小提琴。 – Matholomew