Skip to content

Instantly share code, notes, and snippets.

@jhades
jhades / 01.html
Last active February 25, 2022 14:49
Angular Custom Form Controls: Complete Guide - https://blog.angular-university.io/angular-custom-form-controls
<div [formGroup]="form">
<input placeholder="Course title" formControlName="title">
<input type="checkbox" placeholder="Free course" formControlName="free">
<textarea placeholder="Description" formControlName="longDescription">
</textarea>
@jhades
jhades / 01.html
Last active July 11, 2023 20:12
Angular Custom Form Validators: Complete Guide - https://blog.angular-university.io/angular-custom-validators/
User Login Form:
<form [formGroup]="form">
<input matInput type="email" name="email"
placeholder="Email" formControlName="email">
<input matInput type="password"
placeholder="Password" formControlName="password">
<button [disabled]="!form.valid">
@jhades
jhades / 01.ts
Last active April 28, 2020 11:11
RxJs Error Handling
@Component({
selector: 'home',
templateUrl: './home.component.html'
})
export class HomeComponent implements OnInit {
constructor(private http: HttpClient) {}
ngOnInit() {
@jhades
jhades / 01.ts
Last active October 25, 2021 19:42
RxJs mapping operators
const http$ : Observable<Course[]> = this.http.get('/api/courses');
http$
.pipe(
tap(() => console.log('HTTP request executed')),
map(res => Object.values(res['payload']))
)
.subscribe(
courses => console.log("courses", courses)
export interface Course {
id:number;
description:string;
iconUrl?: string;
courseListIcon?: string;
longDescription?: string;
category:string;
seqNo: number;
lessonsCount?:number;
@NgModule({
declarations: [
AppComponent
],
imports: [
....
StoreModule.forRoot(reducers, { metaReducers }),
!environment.production ? StoreDevtoolsModule.instrument() : []
],
@jhades
jhades / 01.html
Last active April 26, 2018 08:08
Angular @ViewChild Examples
<h2>Choose Brand Colors:</h2>
<color-sample [color]="primary" #primaryColorSample>
</color-sample>
<mat-input-container>
<mat-label>Primary Color</mat-label>
<input matInput #primaryInput [(colorPicker)]="primary" [(ngModel)]="primary"/>
</mat-input-container>
@jhades
jhades / 01.json
Last active June 13, 2021 21:51
Angular Universal Guide
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist-server",
"main": "src/main.server.ts",
"tsConfig": "src/tsconfig.server.json"
}
}
{
"publicKey":"BLBx-hf2WrL2qEa0qKb-aCJbcxEvyn62GDTyyP9KTS5K7ZL0K7TfmOKSPqp8vQF0DaG8hpSBknz_x3qf5F4iEFo",
"privateKey":"PkVHOUKgY29NM7myQXXoGbp_bH_9j-cxW5cO-fGcSsA"
}
import {MatDialogModule} from "@angular/material";
@NgModule({
declarations: [
...
CourseDialogComponent
],
imports: [
...