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-root", | |
| templateUrl: "./app.component.html", | |
| styleUrls: ["./app.component.scss"], | |
| changeDetection: ChangeDetectionStrategy.OnPush, | |
| encapsulation: ViewEncapsulation.None, | |
| }) | |
| export class AppComponent { |
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
| @NgModule({ | |
| exports: [RouterModule], | |
| imports: [ | |
| CommonModule, | |
| RouterModule.forRoot(appRoutes, { | |
| ... | |
| // Restore the last scroll position | |
| scrollPositionRestoration: "enabled", | |
| scrollOffset: [0, 0], | |
| // Enable scrolling to anchors |
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
| import { NavigationEnd, NavigationStart } from "@angular/router"; | |
| /** | |
| * Service that handles scrolling back to top if/when needed, depending on the configured strategies and route config. | |
| * Can be configured through route data, by defining the "scrollBehavior" key and setting it to a valid {RouteScrollBehaviour} value | |
| * References | |
| * https://www.bennadel.com/blog/3534-restoring-and-resetting-the-scroll-position-using-the-navigationstart-event-in-angular-7-0-4.htm | |
| * Potential for improvement from there: listen to scroll events on the DOM | |
| * https://medium.com/angular-in-depth/reactive-scroll-position-restoration-with-rxjs-792577f842c | |
| * https://medium.com/@samisalamiger/great-article-f4f642b134ab |
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
| const appRoutes: CustomRoutes = [ | |
| { | |
| path: "todos", | |
| loadChildren: () => import("@app/todos/feature-shell").then((mod) => mod.TodosFeatureShellModule), | |
| ... | |
| data: { | |
| ... | |
| scrollBehavior: RouteScrollBehaviour.KEEP_POSITION, | |
| }, | |
| ... |
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
| import { ActivatedRoute, NavigationEnd, NavigationStart, Router } from "@angular/router"; | |
| import { Injectable, OnDestroy } from "@angular/core"; | |
| import { ViewportScroller } from "@angular/common"; | |
| import { filter, observeOn, scan } from "rxjs/operators"; | |
| import { asyncScheduler, Subscription } from "rxjs"; | |
| import { | |
| RouterScrollService, | |
| RouteScrollBehaviour, | |
| RouteScrollStrategy, | |
| ScrollPositionRestore, |
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
| @NgModule({ | |
| imports: [ | |
| ... | |
| ], | |
| declarations: [ | |
| ... | |
| ], | |
| exports: [ | |
| ... | |
| ], |
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-root", | |
| templateUrl: "./app.component.html", | |
| styleUrls: ["./app.component.scss"], | |
| changeDetection: ChangeDetectionStrategy.OnPush, | |
| encapsulation: ViewEncapsulation.None, | |
| }) |
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
| sebastien@developassion:~/wks/tmp/test$ git init | |
| Initialized empty Git repository in /home/sebastien/wks/tmp/test/.git/ | |
| sebastien@developassion:~/wks/tmp/test$ git status | |
| On branch master | |
| No commits yet | |
| nothing to commit |
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
| sebastien@developassion:~/wks/tmp/test$ echo "Hello world" > hello.txt | |
| sebastien@developassion:~/wks/tmp/test$ cat hello.txt | |
| Hello world | |
| sebastien@developassion:~/wks/tmp/test$ git status | |
| On branch master | |
| No commits yet | |
| Untracked files: | |
| hello.txt |
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
| class Test { | |
| x; | |
| constructor(b: boolean ) { | |
| if(b) { | |
| this.x = 'hello' | |
| } else { | |
| this.x = 42; | |
| } | |
| } | |
| } |