1

I am new to Angular world.In my project,I want to open a component in a new tab using windows.open() from a contextmenu of ag-grid.These components are being used inside action - an inbuilt function in ag-grid context menu. Since it is inside Ag-grid,other html events cannot be used.

I have a TestScreen1Component which contains an ag-grid with context menu.On click of an item in the COnetxt Menu,I want to open TestScreen2Component in new tab.Currently I am using windows.open() for routing.This works fine in local build.However while doing a Production build by providing a base-href value this url is not working and giving me 404 error.

TestScreen1Component.ts

this.gridOptions.getContextMenuItems = params => {
console.log("getContentMenuItems()");
var result = [
{
name: "Always Disabled",
disabled: true,
tooltip: "Sample"
},
"separator",
{
name: "open Screen",
disabled: false,
action: () => {
window.open("/testScreen2", "_blank");}}];
return result;
};

routing-module.ts
const routes: Routes = [{
{ path: "/testScreen2", component: TestScreen2Component }];
Farhana
  • 11
  • 1
  • Try this url here[Link](https://stackoverflow.com/questions/41355830/angular-2-routing-run-in-new-tab). This may help full. – Manjunatha DL Sep 23 '19 at 07:29

1 Answers1

0

I assume that you were using html5mode for routing in development (with # enabled) and it worked just fine cause it didn't require server side configuration. After you deployed, that mode (probably) is turned off, in that case it will require some server side rewrite configuration.

Apache .htaccess should look like this:

 RewriteEngine on

# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]  
RewriteCond %{REQUEST_FILENAME} -d  
RewriteRule ^ - [L]

# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]  
Nikola Stekovic
  • 635
  • 3
  • 13