1

I am using the Angular CLI to create a new project using the following command

ng new AngularProject

This command creates a folder with my newly created project. I now go to the /src folder to see all the files. But when I open index.html, nothing happens? I just see an empty page. I am aware that you can use ng build to create the /dist folder with the build files or ng serve to run the project with a webserver. But I just want to use all the files from the /src folder without changing the structure of this folder.

How can I get my index.html in the /src folder to work without building or serving?

1
  • You can't. Angular is used to create web apps. Web apps are served from a web server. Not from the file system. The index.html in the src folder is a source file, meant to be transformed by the build. Commented Sep 30, 2017 at 7:12

1 Answer 1

2

Short answer ... you can't. An Angular application cannot be executed in development mode by opening the index.html file.

The ng build command transpiles the code from TypeScript to JavaScript, bundles the code, and updates the index.html file with the defined bundles.

These files can be deployed to a Web server, which will then serve the index.html file appropriately.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.