Using landing page as home path

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
cloudSolutions
Posts: 4
Joined: 06 Sep 2021, 03:19

19 Jun 2022, 23:53

Hi support team, I need your help, I am trying to configure the application to load the home page as landing page using src/assets/pages/landing.html, so far I have managed to load the page but when choosing the menu:

Code: Select all

<div class="landing-topbar-right">
            <a href="#" class="second-menubutton">Login</a>
            <button class="landing-button p-button"><span class="p-button-text">Sign up</span></button>
            <a href="#" id="landing-menu-button" onclick="openMenu()">
                <i class="pi pi-bars"></i>
            </a>
        </div>
        
the app throw the exception:

Code: Select all

Uncaught ReferenceError: openMenu is not defined
    at HTMLAnchorElement.onclick ((index):1:1)
I don't know how to attach the script logic to angular so that it can handle the event, Could you help me ?

cetincakiroglu
Posts: 130
Joined: 17 Dec 2021, 09:33

25 Jul 2022, 14:30

Hi,

First of all, the error you've shared is because the "openMenu" function does not exist in the related component.ts file and you cannot use "onclick" in Angular, and it's not related to the issue you're asking about. When it's come to the routing issue, you can follow the walkthrough below.

Since it's a static HTML file you can't define it as an initial path in Router Module since it requires to address a component or a module to be loaded. In this case, the best approach would be to convert the static HTML into an Angular component.
For example,
1- Use "ng g c landingComponent" command, it will generate a landing-component folder containing a landing.component.ts
2- Import it to the top-level module where the routing happens.
3- Replace the initial route (dashboard) with your landing.component

For more info please visit Angular documentation (https://angular.io/guide/router) it's just how Angular works and it's not related to PrimeNG or any templates.

Regards

Post Reply

Return to “Freya - PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 12 guests