V
V
Victoria Kabishova2020-10-19 14:20:33
Angular
Victoria Kabishova, 2020-10-19 14:20:33

How to open an Angular-cli project in a browser?

Hello, I can not understand why the html page in the Angular project does not open. I created a project through Angular cli. After creation launched - everything works. I started the project with the ng serve command. And this is what he gave out:
5f8d74ce2857c608675880.png
then I created an html page in the project , this
5f8d754474f4d915780206.png
5f8d75549103e515427587.png
is where it is located,
5f8d756e2f139830622912.png
then I compiled the project using the same ng serve command
5f8d758bc3c99195264547.png
and this is what he gave me
5f8d75bdb5c2b234798408.png

What am I doing wrong? The program in which I write the project is Visual Studio 2019 Enterprise
Thanks for the answer.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
CoyoteSS, 2020-10-22
@Parsifal31017

This is because you are not following the architecture of Angular applications, each individual HTML page must have a model associated with it - a TS file, optionally more CSS files and all this together is called a "component". Further, this component must be declared in the @NgModule module, the declarations field, you kind of register it in your application, indicate the TS class of the component there (1 component - 1 module), usually this is AppModule, but that's not all, in the application template ( app.component.html) or any other, insert your component's selector.
Create a component: ng gc something-cmp
Create a module: ng gm something-module The
CLI will automatically create a folder with all the necessary files and import it into the application's appmodule.

B
babtsoualiaksandr, 2020-10-19
@babtsoualiaksandr

Strange structure of the SPA project ))
It gave out exactly what is in index.html => app.component.HTML
And the elements admin, header, company ...... need to be done through the creation of separate components: you can use the CLI
ng gc admin

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question