Open
Description
From @prolink007 on June 15, 2017 15:44
The native element is not available inside AfterViewInit on Android but is available on ios.
For example:
import {AfterViewInit, Component} from "@angular/core";
import {Page} from "tns-core-modules/ui/page";
import {Label} from "tns-core-modules/ui/label";
@Component({
selector: "lifecycle",
moduleId: module.id,
template: `
<GridLayout columns="auto" rows="auto">
<Label id="label1" col="0" row="0"></Label>
</GridLayout>
`
})
export class Lifecycle implements AfterViewInit {
private _page: Page;
constructor(page: Page) {
this._page = page;
}
public ngAfterViewInit(): void {
let label: Label = this._page.getViewById<Label>("label1");
// label.android will be undefined on android
console.log("ngAfterViewInit: " + label.android + label.ios);
}
}
label.android
will be undefined when running on android.
label.ios
is defined when running on ios.
I would expect EVERYTHING to be loaded and ready when ngAfterViewInit
is fired. Because the view is supposed to be ready at that point.
I know you can subscribe to loaded
on the element to know when it is finished loading, but i would expect AfterViewInit
to be called after the entire "dom" is loaded and ready.
Copied from original issue: NativeScript/NativeScript#4396