Base solution for your next web application
Open Closed

Angular open component in new tab, but not the entire application #10341


User avatar
0
KarakTheWise created

Greetings,

I have a simple (I hope) Angular question. I'm not sure how to word the question for a better search in Google so I just thought I would post an image of what I'm trying to achieve. I'm wanting to open the guest-contract component in a new tab without the rest of the application's components. E.g. no left-nav, top-nav and so on.  When I use window.open(...) I get the entire application in a new tab.  I wasn't having any on Stack etc. because I'm not sure what the correct wording for this problem would be :) My current method is just this.

<br>

generateContract(id: number): void {
    window.open('/app/main/events/guest-contract/' + id, '_blank');}

Any suggestions would be great!

Thanks in advance!


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @KarakTheWise

    As far as I know, it is not possible this way. You need to create a new page without the layout and open it using window.open command.

    In easy way, you can hide the items you want like we do for install page, see https://github.com/aspnetzero/aspnet-zero-core/blob/dev/angular/src/app/admin/install/install.component.less or you can create a new module with empty layout and place a new page in this module.

  • User Avatar
    0
    KarakTheWise created

    Excellent! Thank you. I want to be sure I understand.

    #kt_aside, #kt_footer, #kt_header { display: none !important; }

    Does this code in the .less file 'hide' the items you want hidden? I haven't run into this before so it's new to me :)

  • User Avatar
    0
    KarakTheWise created

    Update: #kt_header_mobile was the guilty party :) It looks great now, thanks again!

    I've made some progress. The navigation, header and footer are not showing in the new window. But I'm not sure what to do with this issue: When I go to 'print' and thus save as PDF, the top navigation is still displayed even though it's not displayed in the new window. Any thoughts?

  • User Avatar
    0
    musa.demir created

    Hi @KarakTheWise

    You should also hide #kt_header_mobile see :

    /* print styles */
    @media print {
      #kt_aside, #kt_footer, #kt_header, #kt_header_mobile {
        display: none !important;
      }
    }
    
  • User Avatar
    0
    KarakTheWise created

    Sorry for the slow reply. That was my issue and I really apprciate the help! Thank you.