Answer the question
In order to leave comments, you need to log in
How to bind nested select radio buttons -> select in AngularJS?
We continue to smoke AngularJS.
It is required to pull out the select value, which is nested in radiobuttons.
Code jsfiddle.net/hanze/pqh4eq96html
_
<h1>Select </h1>
<div ng-app="" ng-controller="OrderCtrl">
<div class="radio" ng-repeat="delivery in deliveries">
<label>
<input type="radio" name="radioDelivery" ng-value="delivery" ng-model="$parent.selectedDelivery">
{{delivery.name}}. {{delivery.desc}}
<select>
<option ng-repeat="tax in delivery.tax" ng-value="tax" ng-model="$parent.selectedTax">{{tax.town}} {{tax.price}} $ </option>
</select>
</label>
</div>
<br>Delivery: {{selectedDelivery.name}}
<br>Tax delivery: {{ }} /// Что тут писать??</div>
OrderCtrl = function ($scope) {
$scope.deliveries = [{
name: "RussianPOST",
tax: [{
town: "Moscow",
price: 10,
}, {
town: "Izhevsk",
price: 30,
}]
}, {
name: "DHL",
tax: [{
town: "Moscow",
price: 50,
}, {
town: "Izhevsk",
price: 100,
}]
}
];
$scope.selectedDelivery = $scope.deliveries[0];
}
Answer the question
In order to leave comments, you need to log in
Specially developed for select ng-options , there is just a normal example there.
Copy-paste from a live project (sorry in advance for the ugly code, one of the first implementations of angularjs):
<tr ng-repeat="extraPoint in order.pickpoint" ng-show="form.address.city.name==extraPoint[0].name" class="delivery-section-extra">
<td class="delivery-checkbox pickup-checkbox">
<input ng-click="setPickup(extraPoint[0])"
ng-checked="form.delivery.name==extraPoint[0].name"
type="radio"
ng-required="!giftOnly" />
</td>
<td ng-init="point=extraPoint[0]">
<span ng-click="setPickup(point)">{{extraPoint[0].name}} - бесплатный самовывоз</span>
<select
ng-click="setPickup(point)"
ng-model="point"
ng-options="pickupPoint.desc for pickupPoint in extraPoint">
</select>
</td>
</tr>
There, in the example, there is no connection between radio and select. Interested in how to implement when the user clicks on the selects, so that the radio changes accordingly.
That is, when I select the cost and city of DHL, this service was automatically selected.
On Jquery, this is easily organized, but I want to taste the magic of Angular.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question