var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.cars = [{
model: "Ford Mustang",
color: "red"
},
{
model: "Fiat 500",
color: "white"
},
{
model: "Volvo XC90",
color: "black"
}
];
$scope.cl = function() {
alert($scope.ename)
$scope.selectedCar = ""
}
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
<p>Select a car:</p>
<div ng-repeat="y in cars">
<select ng-model="selectedCar">
<option ng-repeat="x in cars" value="{{x.model}}">{{x.model}}</option>
</select>
</div>
<h1>You selected: {{selectedCar}}</h1>
<button ng-click="cl()">click</button>
</div>
In above code due to ng-repeat every select box getting its own scope due to that when I try to clear all selected option I am not able to so.
Any suggestion?