You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a3e123a
Browse filesBrowse the repository at this point in the historyBrowse files
@@ -144,6 +147,8 @@ This repository contains a list of resources to learn Angular. It includes tutor
144
147
- [PrimeNG](#primeng)
145
148
- [Installing PrimeNG](#installing-primeng)
146
149
- [Importing PrimeNG](#importing-primeng)
150
+
- [SPA](#spa)
151
+
- [Advantages of SPA](#advantages-of-spa)
147
152
- [PWA](#pwa)
148
153
- [Installing PWA](#installing-pwa)
149
154
- [Configuring PWA](#configuring-pwa)
@@ -212,25 +217,9 @@ This repository contains a list of resources to learn Angular. It includes tutor
212
217
213
218
[Back to top⤴️](#table-of-contents)
214
219
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.
Open the browser and navigate to `http://localhost:4200/`.
288
277
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
+
289
309
[Back to top⤴️](#table-of-contents)
290
310
291
311
## Components
@@ -319,22 +339,50 @@ There are several properties that can be defined in the component metadata:
319
339
320
340
**Selector** - Defines the element name or CSS selector that identifies the component in the HTML template.
321
341
342
+
```typescript
343
+
selector: 'app-root'
344
+
```
345
+
322
346
**Providers** - Defines the providers of the component's dependencies.
323
347
348
+
```typescript
349
+
providers: [MyService]
350
+
```
351
+
324
352
**styles** - Defines the inline styles for the component.
325
353
354
+
```typescript
355
+
styles: ['h1 { color: red; }']
356
+
```
357
+
326
358
**styleUrls** - Defines an array of URLs of the stylesheets for the component.
327
359
360
+
```typescript
361
+
styleUrls: ['./app.component.css']
362
+
```
363
+
328
364
**template** - Defines the HTML template for the component.
329
365
366
+
```typescript
367
+
template: '<h1>My Component</h1>'
368
+
```
369
+
330
370
**templateUrl** - Defines the URL of the HTML template for the component.
331
371
372
+
```typescript
373
+
templateUrl: './app.component.html'
374
+
```
375
+
332
376
## Component Creation
333
377
334
378
### Using Angular CLI
335
379
336
380
```bash
337
381
ng generate component [component-name]
382
+
383
+
# or
384
+
385
+
ng g c [component-name]
338
386
```
339
387
340
388
### Manual Creation
@@ -380,7 +428,7 @@ import { Component } from '@angular/core';
380
428
})
381
429
```
382
430
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.
384
432
385
433
**Step 7** - Define the selector, template, and styles for the component.
386
434
@@ -394,6 +442,7 @@ styleUrls - An array of URLs of the stylesheets for the component.
394
442
395
443
```typescript
396
444
export class [ComponentName]Component {
445
+
// Component logic here
397
446
}
398
447
```
399
448
@@ -441,6 +490,10 @@ export class AppComponent {
441
490
442
491
```bash
443
492
ng serve
493
+
494
+
# or
495
+
496
+
ng serve --open
444
497
```
445
498
446
499
### Example
@@ -458,7 +511,7 @@ import { Component } from '@angular/core';
458
511
})
459
512
460
513
export class TestComponent {
461
-
514
+
// Component logic here
462
515
}
463
516
```
464
517
@@ -487,7 +540,9 @@ import { Component } from '@angular/core';
487
540
styleUrls: ['./test-component.component.css']
488
541
})
489
542
490
-
export class TestComponent {}
543
+
export class TestComponent {
544
+
// Component logic here
545
+
}
491
546
```
492
547
493
548
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.
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
5551
5608
5552
5609
[Back to top⤴️](#table-of-contents)
5553
5610
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.
- **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
+
5554
5627
## PWA
5555
5628
5556
5629
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