How to set the default value for radio buttons in AngularJS? -
i need make system change total price number of tickets selected. created radio buttons choose number of ticket. ploblem default value unset , result null on loading.
<input type="radio" ng-model="people" value="1" checked="checked"><label>1</label> <input type="radio" ng-model="people" value="2"><label>2</label> <input type="radio" ng-model="people" value="3"><label>3</label> <ul> <li>{{10*people}}€</li> <li>{{8*people}}€</li> <li>{{30*people}}€</li> </ul>
set default value people
nginit
<div ng-app> <div ng-init="people=1" /> <input type="radio" ng-model="people" value="1"><label>1</label> <input type="radio" ng-model="people" value="2"><label>2</label> <input type="radio" ng-model="people" value="3"><label>3</label> <ul> <li>{{10*people}}€</li> <li>{{8*people}}€</li> <li>{{30*people}}€</li> </ul> </div>
demo: fiddle
Comments
Post a Comment