Empty fiddle for angularjs
by Stepan Kasyanenko
HTML
<div ng-app="ExampleApp">
<div ng-controller="ExampleController">
<h3>
Пример без переменной
</h3>
<ul>
<li ng:repeat="method in methods">
<label>
<input type="radio" name="method" ng:model="deliveryMethod.method" ng-value="method" />{{method.name}}
</label>
</li>
</ul>
<table>
<tr>
<td ng:bind="deliveryMethod.method.price | currency"></td>
</tr>
</table>
<h3>
Пример с переменной
</h3>
<ul>
<li ng:repeat="method in methods">
<label>
<input type="radio" name="method2" ng:model="deliveryMethod2.method" ng-change="deliveryMethod2.myValue = (method.price | currency)" ng-value="method" />{{method.name}}
</label>
</li>
</ul>
<table>
<tr>
<td ng:bind="deliveryMethod2.myValue"></td>
</tr>
</table>
</div>
</div>
CSS
.error {
color: red;
font-style: italic;
}
JavaScript
angular.module('ExampleApp', [])
.controller('ExampleController', function($scope) {
$scope.methods = [{
id: 1,
name: "1",
price:100
}, {
id: 2,
name: "2",
price:200
}];
$scope.deliveryMethod ={method:null};
$scope.deliveryMethod2 ={myValue:null,method:null};
});