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
1 Hrs
20 Min
43 Seg

Componentes en Angular

29/71
Resources

How are Angular applications structured from their components?

In Angular, components are the basis for building robust applications, as if they were Lego pieces that allow you to create large architectures. An Angular component is composed of a template, a CSS and a TypeScript logic file. The communication between the template and the logic is done through property binding and event binding. These allow sending data from the logic to the template and receiving events from the user, such as clicks or key presses, to modify properties of the component.

How to create and organize your own components?

The versatility of Angular is not limited to using only standard HTML tags; you can develop your own components, with custom properties and events. When starting a large project, it is convenient to organize the application into modules or domains. Each domain can represent different sections of the project, such as products, sales or authentication. You can structure your project in this way:

  • Folders per domain: Each domain such as "products" or "sales" will have its own folder.
  • Subfolders for pages and components: Within each domain, you can create:
    • Pages: mainly used in the routing of the application.
    • Components: The reusable blocks that make up these pages.

How to generate components from the terminal?

Once the structure is defined, go to the terminal to start creating the components. Use the command ng generate or its abbreviation ng g. For example:

ng generate component domains/products/pages/list.

This command creates a list page within the products domain. For more specific components, e.g. for an individual product:

ng generate component domains/products/components/product

How to integrate the components into the routing system?

The next step is to modify the routing system so that your application does not depend exclusively on the app component, but allows the use of pages and components defined in your modular project. For this purpose it is used:

  • Router Outlet: this is the element that allows route recognition and component rendering according to the user's navigation.

In the routes file, it ensures that the app component contains the router outlet to activate the routing logic, and defines the necessary routes as the initial empty route ('') rendered by the list component:

const routes: Routes = [ { path: '', component: ListComponent }, // other routes];

Do I need a separate file for each template?

For very small templates, Angular offers flexibility. It is not mandatory to create a separate HTML file for each single template. You could simplify by defining the template directly in the component using the template property instead of templateUrl. Despite this option, if the template requires complex logic, it is preferable to have it in a separate file. This helps to keep the code clean and easy to manage.

How can I reduce the size of the app.component?

The app.component can become very light if you choose to remove a dedicated CSS file and any unnecessary HTML files, as long as you contain the necessary logic within the component:

  • Elimination of unnecessary files: When all global styles are consolidated into a single styles.css file, the app.component's own CSS file can be redundant and removed.
  • Template simplification: If you have a minimal template, define it directly in the component to avoid extra files.

With these actions, you reduce complexity and improve the performance of your application as it grows.

Contributions 7

Questions 2

Sort by:

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

A mi el truco del \<router-outlet /> directo como template del componente no me funciono, me dice que no existe el componente y tengo que crear y ligar un archivo aparte de HTML 🥲
Angular usa `templateUrl` para vincular un archivo HTML separado y `styleUrls` para CSS. Ejemplo típico: ```js templateUrl: './app.component.html', styleUrls: ['./app.component.css'] ``` Si el template es pequeño, podemos usar `template` directamente y omitir `styleUrls`: Ejemplo: ```ts template: '<router-outlet />' ``` **Ventajas:** * **Separación de lógica y vista:** útil para templates grandes y complejos. * **Simplicidad y eficiencia:** ideal para templates pequeños, evita archivos separados innecesarios. **Consideraciones:** * Si el template es pequeño, usar `template` directamente. * Si el template crece, usar `templateUrl`. * Omitir `styleUrls` si no hay estilos específicos o son mínimos.
Gracias por hacerlo Domain Driven <3 es muy poca la gente que aplica domains lastimosamente :(
No me funciono usando el template: '\<router-outlet>\</router-outlet>' a cambio use templateUrl: 'domains/products/pages/list/list.component.html'
Aca estan los comandos ng g c domains/products/pages/list ng g c domains/products/components/product
Estado revisando el curso y las fuentes de GitHub están todos desactualizados o existe un repositorio que no están en los recursos del curso.