Skip to content

Native element not available in AfterViewInit on android #4396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
prolink007 opened this issue Jun 15, 2017 · 2 comments
Closed

Native element not available in AfterViewInit on android #4396

prolink007 opened this issue Jun 15, 2017 · 2 comments

Comments

@prolink007
Copy link

prolink007 commented Jun 15, 2017

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.

@NickIliev
Copy link
Contributor

This issue was moved to NativeScript/nativescript-angular#848

@lock
Copy link

lock bot commented Aug 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Aug 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants