This file contains 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
addTodo(newTodo:Todo):Observable { | |
let obs = this.todoBackendService.saveTodo(newTodo); | |
obs.subscribe( | |
res => { | |
this._todos.next(this._todos.getValue().push(newTodo)); | |
}); | |
return obs; | |
} |
This file contains 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
export class CoursesService() { | |
http: HttpClient; | |
constructor() { | |
this.http = new HttpClient(... dependencies needed by HTTPClient ...); | |
} | |
... | |
} |
This file contains 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
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) |
This file contains 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-root', | |
template: ` | |
<h1>FA Input</h1> | |
<fa-input icon="envelope" (value)="onNewValue($event)"></fa-input> | |
<fa-input icon="lock" (value)="onNewValue($event)"></fa-input> |
This file contains 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
const obs = interval(1000).pipe(take(5)); | |
This file contains 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
export const routeConfig:Routes = [ | |
{ | |
path: 'home', | |
component: Home | |
}, | |
{ | |
path: 'lessons', | |
component: AllLessons | |
} | |
]; |
This file contains 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
"server": { | |
"builder": "@angular-devkit/build-angular:server", | |
"options": { | |
"outputPath": "dist-server", | |
"main": "src/main.server.ts", | |
"tsConfig": "src/tsconfig.server.json" | |
} | |
} |
This file contains 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
onSelectUser(participantId:string) { | |
this.participantsService.findParticipantById(parseInt(participantId)) | |
.pipe( | |
debug(LogginLevel.DEBUG, "Loading participant from backend") | |
) | |
.subscribe( | |
participant => { | |
... | |
}, |
This file contains 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 class="container" *ngIf="userLoggedIn"> | |
.... visible only to authenticated users | |
<button *ngIf="user.admin">Delete User</button> | |
</div> |
This file contains 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', | |
template: ` | |
<button (click)="save()">Save Lesson</button> | |
<lessons-list [lessons]="lessons"></lessons-list> | |
` | |
}) | |
export class App { | |
constructor(private lessonsService: LessonsService) { |