This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component({ | |
| selector: 'some-component', | |
| template: ` | |
| <p-dropDown [options]="users"> | |
| <ng-template let-user> //now we have a local 'user' variable with each user's data | |
| <img [src]="user.avatar" /> | |
| <span> {{ user.label }} </span> | |
| </ng-template> | |
| </p-dropDown> | |
| ` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component({ | |
| selector: 'some-component', | |
| template: ` | |
| <p-lightbox [images]="images"></p-lightbox> | |
| ` | |
| }) | |
| class SomeComponent { | |
| images = [ | |
| {source: 'img.jpg', thumbnail: 'small-img.jpg'}, | |
| {source: 'img2.jpg', thumbnail: 'small-img2.jpg'} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| <p-fileUpload name="myfile[]" url="./upload.php"></p-fileUpload> | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component({ | |
| selector: 'some-component', | |
| template: ` | |
| <p-dialog header="Title" [(visible)]="display"> | |
| Content | |
| </p-dialog> | |
| <button type="text" (click)="showDialog()" pButton icon="fa-external-link-square" label="Show"></button> | |
| ` | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component({ | |
| selector: 'some-component', | |
| template: ` | |
| <p-dropDown [options]="users"></p-dropDown> // options is actually an input, a binding to a list of options for the dropdown to render | |
| ` | |
| }) | |
| class SomeComponent { | |
| users: SelectItem[] = [{value: 1, label: 'Armen Vardanyan'}, {value: 2, label: 'Also Armen Vardanyan'}]; | |
| /* SelectItem is an interface provided by PrimeNG, which has the following form: {label: string, value: any} */ | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component({ | |
| selector: 'app-some-component-with-form', | |
| template: ` | |
| <div [formGroup]="form"> | |
| <div class="form-control"> | |
| <label>First Name</label> | |
| <input type="text" formControlName="firstName" /> | |
| </div> | |
| <div class="form-control"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component({ | |
| selector: 'app-some-component-with-form', | |
| template: ` | |
| <div [formGroup]="form"> | |
| <div class="form-control"> | |
| <label>First Name</label> | |
| <input type="text" formControlName="firstName" /> | |
| </div> | |
| <div class="form-control"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component({ | |
| selector: 'app-single-control-component', | |
| template: ` | |
| <div class="form-control"> | |
| <label>{{ label }}</label> | |
| <input type="text" [formControl]="control" /> | |
| </div> | |
| ` | |
| }) | |
| export class SingleControlComponent{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div> | |
| <app-single-control-component [control]="form.controls['firstName']" [label]="'First Name'"> | |
| </app-single-control-component> | |
| <app-single-control-component [control]="form.controls['lastName']" [label]="'Last Name'"> | |
| </app-single-control-component> | |
| <app-single-control-component [control]="form.controls['age']" [label]="'Age'"> | |
| </app-single-control-component> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface Movie { | |
| id: number; | |
| title: string; | |
| } | |
| @Component({ | |
| selector: 'app-some-component-with-form', | |
| template: `...` // our form is here | |
| }) | |
| export class SomeComponentWithForm { |