Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serving static html outside Angular4

I am a beginner in Angular 4/ Angular 2. I am building an app which consists of

1) static html files( aboutus.html, pricing.html, contact us.html etc), with corresponding css, js files 2) single page application with complex functionality

The first part #1 does not need Angular at all as it's completely static. After login a user comes to #2. From the Angular tutorials that I went through, it seems I need to combine #1 and #2 together and still have to create components etc out of #1, which I feel is unnecessary.

Is there a way, I can build this project such that I can use the static html as is and use Angular only for the dynamic single page app? Any helpful links or examples would be much appreciated.

like image 582
geeky_monster Avatar asked Apr 20 '17 12:04

geeky_monster


4 Answers

If you want to serve static files locally with ng serve, you need to add them either in your assets folder or add to the assets config. See https://github.com/angular/angular-cli/issues/5029

like image 58
Chris Haines Avatar answered Nov 07 '22 23:11

Chris Haines


You can put your static html files into the /assets/ folder.

For example, if you put your aboutus.html file into the folder /assets/static/, then you can link to http://localhost/assets/static/aboutus.html

like image 36
Anthony Cuy HOang Avatar answered Nov 07 '22 23:11

Anthony Cuy HOang


You can't use the router to integrate static html pages, but you still can use normal HTML links. There is no need to name the file that contains the Angular application index.html

like image 7
Günter Zöchbauer Avatar answered Nov 07 '22 23:11

Günter Zöchbauer


In the assets key under apps, you can include any directory you like that you want angular-cli to treat as static. For example, you can declare a folder called static, and serve up static pages from there.

For v6 applications, assets lives under browser:

https://github.com/angular/angular-cli/blob/v6.0.0-rc.8/packages/%40angular/cli/lib/config/schema.json#L521

like image 2
David Lemphers Avatar answered Nov 08 '22 00:11

David Lemphers