У меня есть родительский и дочерний компонент. Детский компонент имеет переменные шаблона, и я хочу их прочитать в родительском.angular2 как просмотреть переменную шаблона, найденную в дочернем компоненте
Родитель:
import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {Page} from "ui/page";
import {ChildComponent} from '/components/child/child.component'
@Component({
selector: "parent",
template: "<child [List]="List"></child>",
directives: [ChildComponent]
})
export class ParentComponent implements OnInit {
// list contains selectable items (<a> tag in HTML)
@ViewChildren("item")
itemsList: QueryList<ElementRef>;
}
ребенок:
import {Component, OnInit, ViewChild, Input} from '@angular/core';
import {Observable} from 'rxjs/Observable';
@Component({
selector: "child",
templateUrl: "components/child/child.html",
})
export class ChildComponent implements OnInit {
@Input() list: array;
.....
}
шаблон: child.html
<li *ngFor="let item of list" style="cursor: default;">
<a (click)="handleClick()" #item > item </a>
</li>
можно получить список пунктов в родительских ??