Skip to content

Instantly share code, notes, and snippets.

@jhades
jhades / 01.ts
Last active Apr 28, 2020
RxJs Error Handling
View 01.ts
@Component({
selector: 'home',
templateUrl: './home.component.html'
})
export class HomeComponent implements OnInit {
constructor(private http: HttpClient) {}
ngOnInit() {
@jhades
jhades / 01.ts
Last active Aug 25, 2019
RxJs mapping operators
View 01.ts
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)
View 01.ts
export interface Course {
id:number;
description:string;
iconUrl?: string;
courseListIcon?: string;
longDescription?: string;
category:string;
seqNo: number;
lessonsCount?:number;
View 01.ts
@NgModule({
declarations: [
AppComponent
],
imports: [
....
StoreModule.forRoot(reducers, { metaReducers }),
!environment.production ? StoreDevtoolsModule.instrument() : []
],
@jhades
jhades / 01.html
Last active Apr 26, 2018
Angular @ViewChild Examples
View 01.html
<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 Jul 5, 2020
Angular Universal Guide
View 01.json
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist-server",
"main": "src/main.server.ts",
"tsConfig": "src/tsconfig.server.json"
}
}
View 01.json
{
"publicKey":"BLBx-hf2WrL2qEa0qKb-aCJbcxEvyn62GDTyyP9KTS5K7ZL0K7TfmOKSPqp8vQF0DaG8hpSBknz_x3qf5F4iEFo",
"privateKey":"PkVHOUKgY29NM7myQXXoGbp_bH_9j-cxW5cO-fGcSsA"
}
View 01.ts
import {MatDialogModule} from "@angular/material";
@NgModule({
declarations: [
...
CourseDialogComponent
],
imports: [
...
@jhades
jhades / 01.ts
Last active Jan 31, 2018
Angular Debugging "Expression has changed after it was checked" Error - Simple Explanation (and Fix)
View 01.ts
@Component({
selector: 'course',
templateUrl: './course.component.html'
})
export class CourseComponent implements AfterViewInit {
@ViewChild(MatPaginator) paginator: MatPaginator;
ngAfterViewInit() {
View 01.ts
import { MatInputModule, MatPaginatorModule, MatProgressSpinnerModule,
MatSortModule, MatTableModule } from "@angular/material";
@NgModule({
declarations: [
...
],
imports: [
BrowserModule,
You can’t perform that action at this time.