JSFiddle - React, Tailwind, and code Playground
by Luiza CICONE
HTML
<div ng-controller="Ctrl">
<div ng-repeat="i in items">
<select ng-model="i.avail" ng-change="changeAvail(i.id, i.avail)">
<option value="true">Available</option>
<option value="false">Unavailable</option>
</select>
</div>
</div>
JavaScript
var app = angular.module('app', []);
app.controller('Ctrl', ['$scope', function($scope) {
$scope.items = [{
avail: 'fdfd',
id: 0
}];
$scope.changeAvail = function(itemId, value) {
if (confirm("You cannot undo this action")) {
//Send an ajax request to backend for an irreversible action
} else {
//Restore input to initial value;
}
}
}]);