htmlangulartypescriptweb

Angular just show index.html and blank screen after build


based on Angular's official website, we should run "ng build" command to create files ready for hosting ( in dist folder ). But after running it, there is no content in index.html. Only the title of the page and if you run it or host it, you will only see a blank page. While if you run the ng serve command, the content will be displayed correctly. What is the problem? Thanks.


Solution

  • You need to deploy your index.html with a deployment server like nginx server, apache server or angular deploy service, etc…

    And make sure that index.html has base url=“/“.

    Here you can check how to deplay with angular: https://angular.io/guide/deployment

    Or

    Apache server: https://httpd.apache.org/