각도 지침 데모 : 이제각도 지침 : 부모 범위 변수에 바인드
<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>'
};
});
:
클릭 A1은 -> B1
클릭 A2를 선택 - > B2 선택됨
클릭 B1 - -> A1 변경되지
클릭 B2가> A2 내가 원하는
을 변경하지 :
클릭 A1을 -> B1 선택
클릭 A2를 -> B2
선택
클릭 B1을 -> A1 선택한
클릭 B2 -> A2
어떻게?
을 문제를 해결할 수 우리는 바인딩을 사용할 수 있습니다 : { 텍스트 : '<' },하지만 부모와 자식 사이에해야 할 일은 무엇입니까? (tet는 부모에게서 아이에게 보여줄 것이다) – cracker