Skip to content

Projeto de estudo de Angular. A ideia é criar uma pagina que será possível cadastrar estabelecimentos, cardápios e seus respectivos pratos.

Notifications You must be signed in to change notification settings

tiago154/food-menu

Repository files navigation

Netlify Status

FoodMenu

This project was generated with Angular CLI version 11.1.4.

Development server

Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Code scaffolding

Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module.

Build

Run ng build to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.

Running unit tests

Run ng test to execute the unit tests via Karma.

Running end-to-end tests

Run ng e2e to execute the end-to-end tests via Protractor.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI Overview and Command Reference page.

Adicionando Angular Material

ng add @angular/material

Criando um novo component

ng generate component components/template/header

ou

ng g c components/template/header

Conceitos Angular

Directives

Attribute Directives

Altera a aparência e o comportamento de um elemento, componente ou outra diretiva

@directive({
  selector: '[appRed]'
})
export class RedDirective {

  constructor(el: ElementRef) {
    el.nativeElement.style.color = '#E35E6B'
  }
}
<i class="material-icons" appRed>
  favorite
</i>

Structural Directives

Altera o layout adicionando e removendo elementos da DOM

<form *ngIf="product">
</form>
<ul>
  <li *ngFor="let product of products">
    {{ product.name }}
  </li>
</ul>

Property Binding

<table [dataSource]="products">
</table>
@Component({
  selector: 'app-product-read',
  templateUrl: './product-read.component.html',
  styleUrls: ['./product-read.component.css']
})
export class HeaderComponent implements OnInit {
  products: Product[]
}

Event Binding

<button mat-raised-button (click)="createProduct()" color="primary">
  Salvar
</button>
@Component({
  selector: 'app-product-create',
  templateUrl: './product-create.component.html',
  styleUrls: ['./product-create.component.css']
})
export class HeaderComponent implements OnInit {
  createProduct(): void {
    // ....
  }
}

One Way Data Binding

Component -> HTML

nome: string;
<input [value]="nome">

Two Way Data Binding

Component <- -> HTML

nome: string;
<input [(ngModel)]="nome">

Schematics

É um template que gera código para instruções complexas.

https://angular.io/guide/schematics

Exemplo: Podemos criar um componente de tabela, que fica responsável de mostrar uma lista de dados, com paginação e ordenação.

ng generate @angular/material:table <nome do componente>

About

Projeto de estudo de Angular. A ideia é criar uma pagina que será possível cadastrar estabelecimentos, cardápios e seus respectivos pratos.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published