2014-04-29 1 views
1

저는 AngularDart에서 라디오 버튼 구성 요소를 만들려고합니다.AngularDart에서 라디오 버튼 구성 요소를 만드는 중 상태를 공유하는 방법은 무엇입니까?

<radio_component currentIndex="0" selectedIndexZ="{{cmp.selectedIndexZ}}" 
    textLabel="Label A"></radio_component> 

<radio_component currentIndex="1" selectedIndexZ="{{cmp.selectedIndexZ}}" 
    textLabel="Label B"></radio_component> 

을 누군가가 내가 다른 라디오 버튼 구성 요소는 CSS 클래스를 변경하려면 자신의 상태를 변경하려면 라디오 버튼 구성 요소 중 하나를 클릭하면 다음과 같이

그래서이 사용됩니다. 누군가 클릭했을 때, 이것들 중 하나의 내부에서 selectedIndexZ를 변경하고 다른 것들을 업데이트하지 않았습니다.

class RadioComponent extends AttachAware with ShadowRootAware { 

    @NgTwoWay('currentIndex') 
    int currentIndex = 0; 

    @NgTwoWay("selectedIndexZ") 
    String selectedIndexZ = "0"; 

누군가가 하나의 라디오 버튼 구성 요소를 클릭하면 다른 사람들이 어떻게 업데이트 될 수 있습니까? 내가 즉, 시간의 부족을 가지고 있기 때문에


, 내가 지금 절대적으로 작업을 얻을해야, 난 그냥이 방법을 복사하고 난거야 미래에 자유 시간을 얻을 경우이 Creating an Angular.Dart Cube component with 6 template arguments

를 작동 이 질문으로 돌아 가라.

답변

0

당신은 조상 요소에 컨트롤러를 사용하고이 컨트롤러에 두 요소의 selectedIndexZ을 바인드해야 (미래에있을 것 단 하나의 루트 컨트롤러)

또한 (다른 구성 요소에 두 요소를 포함 할 수 있습니다 이것은 암시 적으로 컨트롤러 임)이 구성 요소의 필드에 바인딩합니다. 이 방법을 작동해야처럼

@Component(selector: 'parent-element', publishAs: 'par', template: ...) 
class ParentComponent { 

    @NgTwoWay("selectedIndexZ") 
    String selectedIndexZ = "0"; 

} 

템플릿은

<parent-element> 
    <radio_component currentIndex="0" selectedIndexZ="{{par.selectedIndexZ}}" 
    textLabel="Label A"></radio_component> 

    <radio_component currentIndex="1" selectedIndexZ="{{par.selectedIndexZ}}" 
    textLabel="Label B"></radio_component> 
</parent-element> 
+0

같은데,하지만 내가 을 추가 ParentContent에 대한 템플릿을 위해, 나를 위해 메모를 작동하지 않습니다. 라디오 버튼 컨트롤을위한 어딘가에 예제 코드가 있습니까? – Phil

+0

이것이 왜 당신에게 적합하지 않은가요? 콘텐츠와 관련이있는 것은 무엇입니까? –

+0

지금까지 많은 도움을 주셔서 감사합니다.하지만 시간이 부족한 이래로, 즉, 지금 당장이 방법을 사용하면됩니다.이 방법을 복사하면됩니다. http://stackoverflow.com/questions/20723174/creating -an-angular-dart-cube-component-with-6-template-arguments – Phil