T
T
to2n2017-06-27 00:56:48
Angular
to2n, 2017-06-27 00:56:48

How to access controller field from nested template?

Angular >=2
I am using ngx-accordion with markup like this:

<accordion>
  <accordion-group *ngFor="...">
    <accordion-heading>
       {{isOpened}}
    </accordion-heading>
  </accordion-group>
</accordion>

The accordion-group component has an isOpened field. How can I get its value in nested markup?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
ozknemoy, 2017-06-27
@to2n

through #group you take the contents of the entire class and pick up the value of group?.isOpen

<accordion-group #group>
    <div accordion-heading>
      I can have markup, too!
      <i class="pull-right float-xs-right glyphicon"
         [ngClass]="{'glyphicon-chevron-down': group?.isOpen, 'glyphicon-chevron-right': !group?.isOpen}"></i>
    </div>
    This is just some content to illustrate fancy headings.
  </accordion-group>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question