Introducción a Angular y Fundamentos

1

Aprende Angular 17

2

Creando tu primer proyecto en Angular

3

Implementando estilos

4

Mostrando elementos

5

Property Binding en Angular

6

Event Binding: click y doble click

7

Event binding: keydown

8

Modelo de reactividad con Signals

9

Creando un Signal en Angular

Estructuras de control en Angular

10

Directivas de control

11

Uso de ngFor

12

ngFor para objetos

13

Update Tasks

14

Uso de ngIf

15

Uso de ngSwitch y ngSwitchDefault

16

Controlando un input

17

Manejo de formularios en Angular

Alistando tu aplicación para producción

18

Estilos al modo Angular

19

Clases en Angular

20

Editing mode

21

Estados compuestos con computed

22

Usando effect para localStorage

23

Uso de ngbuild

24

Despliegue con Firebase Hosting

25

Nueva sintaxis en Angular

26

Directivas @For, @switch

27

Migrando a la nueva sintaxis de Angular v17

Componentes Reutilizables y Comunicación

28

Construyendo un e-commerce en Angular

29

Componentes en Angular

30

Mostrando los componentes

31

Angular DevTools

32

Uso de Inputs en Angular

33

Uso de Outputs en Angular

34

Componentes para Producto

Ciclo de vida de los componentes

35

Ciclo de vida de componentes

36

Ciclo de vida de componentes: ngOnChanges

37

Ciclo de vida de componentes: ngOnInit

38

Detectando cambios en los inputs

39

Evitando memory leaks con ngDestroy

40

Audio player con ngAfterViewInit

41

Creando la página "about us" o "conócenos"

Mejorando la interfaz del producto

42

Creando componente de productos

43

Creando el Header

44

Creando el carrito de compras

45

Comunicación padre e hijo

46

Calculando el total con ngOnChanges

47

El problema del prop drilling

48

Reactividad con signals en servicios

49

Entendiendo la inyección de dependencias

Integración y Datos

50

Obteniendo datos una REST API

51

Importaciones cortas en Typescript

52

Pipes en Angular

53

Construyendo tu propio pipe

54

Utilizando librerías de JavaScript en Angular

55

Conociendo las directivas

56

Deployando un proyecto en Vercel

Enrutamiento y Navegación

57

Ruta 404

58

Uso del RouterLink

59

Vistas anidadas

60

Uso del RouterLinkActive

61

Detalle de cada producto

62

Obteniendo datos del producto

63

Galería de imagenes

64

Detalle de la galería

Perfeccionando tu e-commerce

65

Mostrando categorias desde la API

66

Url Params

67

LazyLoading y Code Splitting

68

Aplicando LazyLoading

69

Prefetching

70

Usando la nueva sintaxis de Angular 17

71

Lanzando tu aplicación a producción

You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesión a prueba de IA

Antes: $249

Currency
$209
Suscríbete

Termina en:

0 Días
10 Hrs
14 Min
42 Seg

Directivas @For, @switch

26/71
Resources

How is the new for loop syntax in Angular?

Efficiency and clarity are crucial aspects in software development. Angular has introduced improvements in the syntax of for loops, facilitating not only the visual handling of lists, but also optimizing performance. Let's see how this improvement translates in practice.

Implementation of the new syntax

  1. Basic structure: In the new syntax, the use of ngFor is maintained, but with some particularities that favor performance. It is no longer necessary to specify the complete structure inside the ngFor; it is enough to mention the element to iterate:

    <ul> <li*for="let tax of taxes; trackBy: trackByTax"> {{ i }} - {{ tax }} </li></ul></ul>
    • trackBy: Using this option is crucial for performance. It allows Angular to uniquely identify each item in the list, avoiding unnecessary re-rendering.
    • Index tracking: The i variable captures the current position in the loop.
  2. Empty list handling: The empty variable is introduced to handle empty lists in a more declarative way, a point that previously implied additional conditions:

    <li*for="empty">Thelist is empty</li>.

Benefits of the new syntax.

  • Improved performance: By reducing DOM complexity and leveraging trackBy, the rendering process is more efficient.
  • Code clarity and cleanliness: Through a more concise syntax, code maintenance and comprehension are significantly improved.

What changes does the new switch syntax in Angular bring?

The switch operator also undergoes an evolution that allows for clearer and more efficient code, while retaining the functionality known to JavaScript developers.

Migration to the new syntax

  1. Use of the switch element: The new form is more similar to the traditional JavaScript switch, but now all inside Angular directives:
    <div*switch="person.name"> <p*case="'Nicolás'">Iam Nicolás</p> <p*case="'Julián'">Iam Julián</p> <p*case="'Ana'">Iam Ana</p> <p*case="default">Iam nobody</p></div>
    • Case declaration: Individual case structures are maintained for specific categories.
    • Default case: Defined by default, used when no case matches.

Advantages of the new syntax

  • Code maintenance: Makes it easier to understand and adapt the control flow.
  • Consistency with JavaScript: By maintaining similarities with traditional switch concepts, developers adapt quickly.

Why is it important to adopt these new enhancements in Angular?

Adopting these syntactic enhancements not only means embracing a more modern and streamlined code design, but also taking advantage of improved performance and maintainability.

  • Increased efficiency: Applying Angular's native trackBy and methods to handle conditions allows developers to minimize loading and processing times.
  • Ease for the future: With a more precise control structure, development teams can quickly adapt changes and add new functionality without compromising the stability of existing code.

Updating these syntaxes is a best practice for any Angular developer who wants to stay on the cutting edge of web application efficiency.

Contributions 8

Questions 0

Sort by:

Want to see more contributions, questions and answers from the community?

Me parece mas amigable esta versión y me parece que hicieron la estructura parecida a c o java ... o cualquier lenguaje tradicional al menos en cuanto a la estructura
es muy parecido a razor en c#, pero mejor. me agrada mucho la nueva forma. el hecho de no usar ng-template es muy bueno.
Esto definitivamente es un avance, la verdad que al inicio del curso me había empezado a encariñar mucho con las directivas, se siente como muy integradas con HTML, pero es cierto que su legibilidad no era la mejor, ahora con esta nueva sintaxis se siente muy cómodo y además que es fácil de interpretar, que es lo más importante

tengo una pregunta para la gente de aportes que sabe demasiado que diferencia puede haber de estas dos formas ```js @for (task of tasks(); track $index) ``````js @for (task of tasks(); track task; let i = $index) ```
Wao! Me gusta mucho esta nueva forma de escribir las estructuras de control, es más limpio y conocido con otros lenguajes.
cierto parecido a php (laravel)
Me permitió hacerlo con esta sintaxis: \
    @for (item of tasks(); track $index) {            \
  • {{$index+1}} {{item}}\
  •         }@empty {            \
  • \Lista vacia\\
  •         }    \