M. Nalbant M. Nalbant - 1 month ago 6
AngularJS Question

List of buttons that set value to model and submit

I want to make a list of buttons that will set a value in the selectedTime model.
Below is the code that i got, it shows how i want it to look but could be completely wrong.



<form name="room" ng-submit="vm.postEvent()">
<button ng-click="vm.selectedTime = 15" > 15</button>
<button ng-click="vm.selectedTime = 30" > 30</button>
<button ng-click="vm.selectedTime = 60" > 60</button>
</form>




Answer

You don't need to have a form in order to doing this. Just 3 buttons are enought

<button ng-click="vm.selectedTime = 15" > 15</button>
<button ng-click="vm.selectedTime = 30"> 30</button>
<button ng-click="vm.selectedTime = 60"> 60</button>
Comments