0
votes

While I try to mix everything up, using Angular, bootstrap, and node.js / express I am stucked on middle of my way.

I created my component using this (good) tutorial : https://trinitytuts.com/create-simple-web-application-with-angular-2/

I found out that I had to 'ng buid' on client side and push everything on the server, but while I try to load my component on the server side I just get : "Loading..." and nothing. On developer console / network I can see the index.html is loaded from proper directory, but all sub elements are loaded from root (/) instead of 'trinity-app' directory see : https://www.rdv.li/trinity-app/

Sorry if it sound as a verry newbie question, how could I 'force' the angular component to load it's subelements from it's directory instead of root ?

in express I added :

app.use(
    '/trinity-app',
    express.static(
        path.join(__dirname,'trinity-app', 'dist')
    )
);

every clue will be greatly appreciated

regards

greg

1
I found a clue, the generated index.html in dist folder has <base href="/">, it works if I manualy change to <base href="/trinity-app/dist/">, but it's erased every time I regenerate the component, how (and where) could I configure this option ? - Gregoire Mulliez
I found a workaroud, : ng build --base-href /trinity-app/dist - Gregoire Mulliez

1 Answers

0
votes

I found a workaroud, : ng build --base-href /trinity-app/dist It's not a clean solution, but it works