Unable to open modal popup using nativescript


this is the error thrown:
Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<UIAlertController: 0x16bc5600>)

code snippets:

import { alert } from "ui/dialogs";
 displayAlertDialog() {
    let options = {
        title: "Race selection",
        message: "Race chosen: Unicorn",
        okButtonText: "OK"
       alert(options).then(() => {
        console.log("Race chosen!");

Am i missing any package to import

Please suggest


May I know when exactly you are calling displayAlertDialog()?



<StackLayout class="p-15"sdkExampleTitle sdkToggleNavButton>
        <Button text="Display Alert Dialog" (tap)="displayAlertDialog()" class="btn btn-primary btn-active" ></Button>


added page-router-outlet in app component but its not working


modal popup is working now after adding navigation properly