Currently, I am utilizing Visual Studio Code for Ionic 3 development with AngularJS/Typescript. In my code, I am using this.navCtrl.push() to navigate to different pages within the application. Specifically, I have two classes/pages named "level1" and "level2" that I need to dynamically navigate to.
this.navCtrl.push(level2)
When directly specifying the class/page name like above, everything works smoothly. However, when attempting to use a variable:
levelNbr: any;
if(value == null)
{
this.levelNbr = "level1"
}
else
{
this.levelNbr = "level2"
}
this.navCtrl.push(this.levelNbr)
An error is encountered stating:
Uncaught (in promise): invalid link: level2
This suggests that although it identifies "level2", it fails to open the respective page. Is there a way to successfully navigate to a page by using a variable?
Thank you
The following code snippets were used:
import { level1 } from './../levels/levels';
import { level2 } from './../levels/levels';
//all classes are in one file called levels
In the app.modules.ts file, they are also declared.