Redirect to Angular 2 URL


I’m trying to use Electron to package an app I wrote using Angular 2. With Angular 2 it generates a single index.html file and a bunch of js code that loads the various “pages”. In a browser you access a page via parameters added to the URL. So for example…


goes to my launch page and


goes to a settings page

what I would like to do is make it so my Electron exe loads the settings page when it starts with a specific CLI flag. How do I load the index.html from a file, then redirect to a URL that’s relative to that?


Never mind I figured it out on my own. I changed the routing method to hash and then I used url.format to load the file index.html with the hash of the page I wanted to redirect to


Can you please post some tutorial on how to add electron to angular2 project done with angular/cli? I have asked a question here: but noone answers


I use electron-packager…

Makes the whole process much simpler.

Also when you build your angular project set the base href to ./


Here are the exact configs I use from my package.json…

“build”: “ng build --prod -aot -bh ./”,
“electron”: “xcopy /Y “electron\.” “dist” && electron-packager ./dist --icon=icon.ico --out=”…\build\desktop" --platform=win32 --arch=ia32 --asar --overwrite",

I have a folder in the main angular project folder called “electron” which contains the entry.main.js file and the package.json file for electron. I also have a windows ico file I created in the main angular project folder.

I run npm run build first, then npm run electron. That generates the electron packaged file, and all it’s dependencies, in a folder one level above the angular project called “build”.