我在ng repeat中有一个下拉列表和一个add按钮,可以将新的下拉列表添加到列表中,正如我在JSFiddle中所示,我想限制第二个下拉列表,以选择第二个下拉列表中的第一个选定值。因此,不应允许在第一个下拉列表中选择或隐藏第一个下拉列表中选择的值。
在我以前的问题中,pankaj parkar给出了答案,但我无法将该答案集成到我的JSFIDLE中。
ng-repeat="post in posts | filter: { type: selectedValue }"
请在这方面帮助我。
This is my old question
My JSFiddle.
var app = angular.module('angularjs-starter', []);
app.controller('MainCtrl', function($scope) {
$scope.names = ['Mobile','Office','Home'];
$scope.choices = [{id: 'choice1'}];
$scope.addNewChoice = function() {
var newItemNo = $scope.choices.length+1;
$scope.choices.push({'id':'choice'+newItemNo});
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="angularjs-starter" ng-controller="MainCtrl">
<fieldset ng-model='y' ng-repeat="choice in choices">
<select>
<option ng-model='x1' ng-repeat = "x in names">{{x}}</option>
</select>
</fieldset>
<button class="addfields" ng-click="addNewChoice()">Add fields</button>
</div>