Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa | ||
|
wiki2:angular:concrete [2016/07/17 13:22] alfred [Templates] |
wiki2:angular:concrete [2020/05/09 09:25] (actual) |
||
|---|---|---|---|
| Línea 4: | Línea 4: | ||
| ==== Lifecycle hooks ==== | ==== Lifecycle hooks ==== | ||
| <code javascript> | <code javascript> | ||
| - | app/app.component.ts (ngOnInit stub) | ||
| - | |||
| import { OnInit } from '@angular/core'; | import { OnInit } from '@angular/core'; | ||
| Línea 14: | Línea 12: | ||
| </code> | </code> | ||
| + | ==== Call method of a nested component ==== | ||
| + | <code html> | ||
| + | <nk-activities #nkActivities></nk-activities> | ||
| + | <a style="cursor:pointer;" (click)="nkActivities.createActivity(0, 'Talk')">Dialogue</a> | ||
| + | </code> | ||
| ===== Templates ===== | ===== Templates ===== | ||
| ==== Access to HTML tags ==== | ==== Access to HTML tags ==== | ||
| Línea 27: | Línea 30: | ||
| <button type="button" class="btn btn-default" (click)="updateMission(missionForm.form.controls)"><span class="glyphicon glyphicon-open" aria-hidden="true"></span> Update Name</button> | <button type="button" class="btn btn-default" (click)="updateMission(missionForm.form.controls)"><span class="glyphicon glyphicon-open" aria-hidden="true"></span> Update Name</button> | ||
| | | ||
| + | </code> | ||
| + | |||
| + | ==== ngFor with index ==== | ||
| + | <code html> | ||
| + | <ul> | ||
| + | <li *ngFor="let item of items; let i = index"> | ||
| + | {{i}} {{item}} | ||
| + | </li> | ||
| + | </ul> | ||
| + | </code> | ||
| + | |||
| + | ==== Combining ngFor and ngIf ==== | ||
| + | <code> | ||
| + | <select class="form-control" [(ngModel)]="value" (change)="valueChanged.emit($event.target.value)" name="content"> | ||
| + | <template ngFor let-f [ngForOf]="files"> | ||
| + | <option [value]="f.id">{{f.name}}</option> | ||
| + | </template> | ||
| + | </select> | ||
| </code> | </code> | ||
| ===== Others ===== | ===== Others ===== | ||