Posts: 3
Joined: Fri Dec 01, 2023 9:35 am

QR Code and Reader

I wish to add a QR code to 5 pages (app pages) with the value of that page it's currently on

Then using the scanner, I wish someone to be able to be taken directly to that page

The template shows how we can type a value in but how do I get the value of a page within my app so if scanned it would take me to that page?

UPDATE: I have managed to get the QR to be generated using PageName and _id which is great

Now, however when i scan the QR code, it brings in:
PageName 65646845f5454848g684a774654

I have tried to split this using:

Code: Select all

let text = this.code;
const myArray = text.split(" ");

let page = myArray[0];
let _id = myArray[1];
But i'm getting an error:
TypeError: Cannot read properties of undefined (reading 'split')

Can anyone help please?

UPDATE: I have managed to solve this, I was doing this in the wrong place,

Now, however, I am getting a different error

Using this after splitting my values:

Code: Select all

let page = await this.$"navToPage");
I get this error:
Error: NG04002: Cannot match any routes. URL segment: 'lizardprofile'

UPDATE: The above error has now been solved

Now, I am getting a different error. When scanning a QR code i get the correct information back. GREAT.

Now, I wish to navigate to said page. This always takes 2 x scans. This first one restarts the APP, then the second one take me to the correct page.

I am setting 2 variables:

Code: Select all

let text = value;
const myArray = text?.split(" ");

let page = myArray[0];
let _id = myArray[1];
//let url = page.replace("'","");

if(page == "LizardProfilePage")
    this.$"lizardId", _id);
    this.$"navToPage", page);
Then immediately after i am navigating to the page:

Code: Select all

let goToPage = await this.$"navToPage");
await this.$a.navigation.forward(goToPage);
Its like the setting of the variable is happening after i have navigated to the page which looking at the code above, I am setting before navigating.

Does anyone have any pointers on this incase I have missed something?

Return to “Issues”