Skip to content

Commit

Permalink
Angular Forms In Depth
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Jan 15, 2021
1 parent 2617c0d commit a3ec5de
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

</mat-radio-group>

<file-upload requiredFileType="image/png"></file-upload>
<file-upload formControlName="thumbnail"
requiredFileType="image/png"></file-upload>

<mat-form-field>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class CreateCourseStep2Component implements OnInit {
Validators.max(9999),
Validators.pattern("[0-9]+")
]],
thumbnail: [null],
promoStartAt: [null],
promoEndAt: [null]
}, {
Expand Down
11 changes: 9 additions & 2 deletions src/app/file-upload/file-upload.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@ import {Component, Input} from '@angular/core';
import {HttpClient, HttpEventType} from '@angular/common/http';
import {catchError, finalize} from 'rxjs/operators';
import {of} from 'rxjs';
import {ControlValueAccessor} from '@angular/forms';
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';


@Component({
selector: 'file-upload',
templateUrl: "file-upload.component.html",
styleUrls: ["file-upload.component.scss"]
styleUrls: ["file-upload.component.scss"],
providers: [
{
provide: NG_VALUE_ACCESSOR,
multi: true,
useExisting: FileUploadComponent
}
]
})
export class FileUploadComponent implements ControlValueAccessor {

Expand Down

0 comments on commit a3ec5de

Please sign in to comment.