Angular:
jsfiddle
<div ng-app="myApp"> <script> function Contrl($scope){ $scope.parval = 0; $scope.items = [ {id: 1, text: '1'}, {id: 2, text: '2'}, {id: 3, text: '3'} ]; } </script> <div ng-controller="Contrl"> A: <input type="radio" value="1" ng-model="parval">1</input> <input type="radio" value="2" ng-model="parval">2</input> <input type="radio" value="3" ng-model="parval">3</input> <item parval="parval" items="items"></item> </div>
angular.module('myApp', []) .directive('item', function() { return { restrict: 'E', replace: true, scope: { parval: '=', items: '=' }, template: '<div>' + 'B: <span ng-repeat="i in items">' + '<input value="{{i.id}}" type="radio" ng-model="parval">{{i.text}}</input> ' + '</span>' + '</div>' }; });
Now:
Choose A1 → B1, selected
Choose A2 → B2
Press B1 → A1 not changed
Press B2 → A2 not changed
I want to:
Choose A1 → B1, selected
Choose A2 → B2
Choose B1 → A1.
Choose B2 → A2, selected
How?
source share