Skip to content

Commit a3e123a

Browse files
committed
docs: Update README.md with SPA section and project structure
1 parent 90230cb commit a3e123a

1 file changed

Lines changed: 93 additions & 20 deletions

File tree

‎README.md‎

Lines changed: 93 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ This repository contains a list of resources to learn Angular. It includes tutor
1414
![GitHub repo size](https://img.shields.io/github/repo-size/manthanank/learn-angular)
1515
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/manthanank/learn-angular)
1616
![GitHub contributors](https://img.shields.io/github/contributors/manthanank/learn-angular)
17+
![GitHub forks](https://img.shields.io/github/forks/manthanank/learn-angular)
18+
![GitHub stars](https://img.shields.io/github/stars/manthanank/learn-angular)
19+
![GitHub watchers](https://img.shields.io/github/watchers/manthanank/learn-angular)
1720

1821
## Table of Contents
1922

@@ -144,6 +147,8 @@ This repository contains a list of resources to learn Angular. It includes tutor
144147
- [PrimeNG](#primeng)
145148
- [Installing PrimeNG](#installing-primeng)
146149
- [Importing PrimeNG](#importing-primeng)
150+
- [SPA](#spa)
151+
- [Advantages of SPA](#advantages-of-spa)
147152
- [PWA](#pwa)
148153
- [Installing PWA](#installing-pwa)
149154
- [Configuring PWA](#configuring-pwa)
@@ -212,25 +217,9 @@ This repository contains a list of resources to learn Angular. It includes tutor
212217

213218
[Back to top⤴️](#table-of-contents)
214219

215-
## SPA
216-
217-
**SPA** (Single Page Application) is a web application that dynamically rewrites the current page instead of loading entire new pages from the server, providing a fluid and responsive user experience.
218-
219-
### Advantages of SPA
220-
221-
- **Faster Load Times**: Loads the initial page once; subsequent interactions update dynamically.
222-
- **Better User Experience**: No full page reloads, allowing faster navigation and smoother transitions.
223-
- **Reduced Server Load**: Less server load as only necessary data is fetched.
224-
- **Improved SEO**: Optimizable for search engines with server-side rendering and meta tags.
225-
- **Offline Support**: Accessible offline using service workers and caching.
226-
- **Mobile Support**: Optimized for mobile with responsive design and touch gestures.
227-
- **Scalability**: Handles many users and interactions with performance optimizations like lazy loading.
228-
229-
[Back to top⤴️](#table-of-contents)
230-
231220
## Roadmap
232221

233-
[https://roadmap.sh/angular](https://roadmap.sh/angular)
222+
[Angular Roadmap](https://roadmap.sh/angular)
234223

235224
## Configuration
236225

@@ -286,6 +275,37 @@ ng serve
286275

287276
Open the browser and navigate to `http://localhost:4200/`.
288277

278+
Project structure:
279+
280+
```bash
281+
[PROJECT NAME]
282+
├── node_modules
283+
├── public
284+
│ ├── favicon.ico
285+
│ └── ...
286+
├── src
287+
│ ├── app
288+
│ │ ├── app.component.css
289+
│ │ ├── app.component.html
290+
│ │ ├── app.component.spec.ts
291+
│ │ ├── app.component.ts
292+
│ │ ├── app.config.ts
293+
│ │ ├── app.routes.ts
294+
│ │ └── ...
295+
│ ├── index.html
296+
│ ├── main.ts
297+
│ ├── styles.css
298+
│ └── ...
299+
├── .editorconfig
300+
├── .gitignore
301+
├── angular.json
302+
├── package.json
303+
├── README.md
304+
├── tsconfig.json
305+
├── tslint.json
306+
└── ...
307+
```
308+
289309
[Back to top⤴️](#table-of-contents)
290310

291311
## Components
@@ -319,22 +339,50 @@ There are several properties that can be defined in the component metadata:
319339

320340
**Selector** - Defines the element name or CSS selector that identifies the component in the HTML template.
321341

342+
```typescript
343+
selector: 'app-root'
344+
```
345+
322346
**Providers** - Defines the providers of the component's dependencies.
323347

348+
```typescript
349+
providers: [MyService]
350+
```
351+
324352
**styles** - Defines the inline styles for the component.
325353

354+
```typescript
355+
styles: ['h1 { color: red; }']
356+
```
357+
326358
**styleUrls** - Defines an array of URLs of the stylesheets for the component.
327359

360+
```typescript
361+
styleUrls: ['./app.component.css']
362+
```
363+
328364
**template** - Defines the HTML template for the component.
329365

366+
```typescript
367+
template: '<h1>My Component</h1>'
368+
```
369+
330370
**templateUrl** - Defines the URL of the HTML template for the component.
331371

372+
```typescript
373+
templateUrl: './app.component.html'
374+
```
375+
332376
## Component Creation
333377

334378
### Using Angular CLI
335379

336380
```bash
337381
ng generate component [component-name]
382+
383+
# or
384+
385+
ng g c [component-name]
338386
```
339387

340388
### Manual Creation
@@ -380,7 +428,7 @@ import { Component } from '@angular/core';
380428
})
381429
```
382430

383-
If you want to create a standalone component, set the `standalone` property to `true`. If you want to create a non-standalone component, set the `standalone` property to `false`. The standalone component is enabled by default in Angular v17 and later.
431+
If you want to create a non-standalone component, set the `standalone` property to `false`. The standalone component is enabled by default in Angular v17 and later.
384432

385433
**Step 7** - Define the selector, template, and styles for the component.
386434

@@ -394,6 +442,7 @@ styleUrls - An array of URLs of the stylesheets for the component.
394442

395443
```typescript
396444
export class [ComponentName]Component {
445+
// Component logic here
397446
}
398447
```
399448

@@ -441,6 +490,10 @@ export class AppComponent {
441490

442491
```bash
443492
ng serve
493+
494+
# or
495+
496+
ng serve --open
444497
```
445498

446499
### Example
@@ -458,7 +511,7 @@ import { Component } from '@angular/core';
458511
})
459512

460513
export class TestComponent {
461-
514+
// Component logic here
462515
}
463516
```
464517

@@ -487,7 +540,9 @@ import { Component } from '@angular/core';
487540
styleUrls: ['./test-component.component.css']
488541
})
489542

490-
export class TestComponent {}
543+
export class TestComponent {
544+
// Component logic here
545+
}
491546
```
492547

493548
You can create a standalone component by setting the `standalone` property to `true`. The standalone component is enabled by default in Angular v17 and later. You can disable the standalone component by setting the `standalone` property to `false` in the `@Component` decorator of the component. If you disable the standalone component, you need to import the component in the `app.module.ts` file. If you created a non-standalone component, you will see no standalone property in the `@Component` decorator.
@@ -751,6 +806,8 @@ export class AppComponent {
751806
}
752807
```
753808

809+
[Stackblitz Example](https://stackblitz.com/edit/stackblitz-starters-xfz4uk?file=src%2Fmain.ts)
810+
754811
### Shadow DOM View Encapsulation
755812

756813
Uses native shadow DOM to encapsulate styles within the component, preventing them from affecting other components.
@@ -5551,6 +5608,22 @@ To use PrimeNG in an Angular application, you need to import the required styles
55515608

55525609
[Back to top⤴️](#table-of-contents)
55535610

5611+
## SPA
5612+
5613+
**SPA** (Single Page Application) is a web application that dynamically rewrites the current page instead of loading entire new pages from the server, providing a fluid and responsive user experience.
5614+
5615+
### Advantages of SPA
5616+
5617+
- **Faster Load Times**: Loads the initial page once; subsequent interactions update dynamically.
5618+
- **Better User Experience**: No full page reloads, allowing faster navigation and smoother transitions.
5619+
- **Reduced Server Load**: Less server load as only necessary data is fetched.
5620+
- **Improved SEO**: Optimizable for search engines with server-side rendering and meta tags.
5621+
- **Offline Support**: Accessible offline using service workers and caching.
5622+
- **Mobile Support**: Optimized for mobile with responsive design and touch gestures.
5623+
- **Scalability**: Handles many users and interactions with performance optimizations like lazy loading.
5624+
5625+
[Back to top⤴️](#table-of-contents)
5626+
55545627
## PWA
55555628

55565629
Progressive Web Apps (PWAs) are web applications that provide a native app-like experience to users, including offline support, push notifications, and home screen installation. Angular provides built-in support for creating PWAs using the @angular/pwa package.

0 commit comments

Comments
 (0)