I have been looking for ages on the documentation and source code of Angular, but so far no luck.
import {
ContentChildren,
QueryList
} from '@angular/core';
import { AwesomeComponent } from './awesome.component';
@Component({
selector: 'cool-dad',
templateUrl: './cool-dad.template.html'
})
export class CoolDadComponent {
@Input() loop = false;
@Input() automatic = false;
@ContentChildren(AwesomeComponent) items: QueryList<AwesomeComponent>;
someFunc() {
this.items.forEach(item => { console.log(item)});
}
}
With the above code I get a reference to the component, I can set it's properties and call it's public methods. That's great, but I also need access to it's html properties, such as width, height, etc.
import {
ContentChildren,
ElementRef,
QueryList
} from '@angular/core';
import { AwesomeComponent } from './awesome.component';
@Component({
selector: 'cool-dad',
templateUrl: './cool-dad.template.html'
})
export class CoolDadComponent {
@Input() loop = false;
@Input() automatic = false;
@ContentChildren(AwesomeComponent, { read: ElementRef }) items: QueryList<AwesomeComponent>;
someFunc() {
this.items.forEach(item => { console.log(item)});
}
}
With the above code I get the native element and therefore I can get access to all the html properties, but I loose all the access to the components methods.
How can I get both?