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> 

please see jsfiddle.

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

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -