我需要一个系统来改变总价格乘以选择的票数。我创建了一些单选按钮来选择票数。 ploblem是默认值为unset,加载时结果为null。
<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>
为使用
ngInit的人设置默认值
原文链接:https://www.f2er.com/angularjs/146314.html<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>
演示:Fiddle