I have created n new angular app using angular-cli.
I completed the app and preview it using ng-serve, it is working perfectly.
After that I used ng build --
http-server doesn't support client-side routing, so nothing other than your base URL is going to work. Instead, you can use angular-http-server:
npm install -g angular-http-server
ng build --prod
cd dist
angular-http-server
This should only be used to test the app locally before deploying it on a Web server. To learn how to actually deploy the app on a Web server, check out the Angular.io article on deployment, which discusses considerations to make when building for deployment and provides configurations for a variety of different Web servers commonly used in production.
Use ng build
with the --bh
flag
Sets base tag href to /myUrl/ in your index.html:
ng build --base-href /myUrl/
ng build --bh /myUrl/
I'm using the latest version of the Angular-CLI (at the time of this reply its 1.0.0Beta-18)
The way this version works is it puts everything in bundle files and it calls them in the index.html file. After that you have to copy your assets over to the dist folder (for some reason it does not do that). Finally, double check your base href make sure its set to what it needs to be set to and then it should work. That's what worked for me and I've tested on both Apache and Node.