Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120263847
app.component.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Jul 3, 02:20
Size
1 KB
Mime Type
text/x-java
Expires
Sat, Jul 5, 02:20 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
27163876
Attached To
R8244 Eawag_Swing_Weight_Elicitation
app.component.ts
View Options
import { Component, OnInit } from '@angular/core';
import { AuthenticationService } from './authentication.service';
import { Title } from '@angular/platform-browser';
import { Router, NavigationStart, NavigationEnd } from '@angular/router';
import { Location, PopStateEvent } from "@angular/common";
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent implements OnInit {
private lastPoppedUrl: string;
private yScrollStack: number[] = [];
constructor(public auth: AuthenticationService, private title: Title,private router: Router, private location: Location) {}
ngOnInit() {
this.title.setTitle('Admin');
this.location.subscribe((ev:PopStateEvent) => {
this.lastPoppedUrl = ev.url;
});
this.router.events.subscribe((ev:any) => {
if (ev instanceof NavigationStart) {
if (ev.url != this.lastPoppedUrl)
this.yScrollStack.push(window.scrollY);
} else if (ev instanceof NavigationEnd) {
if (ev.url == this.lastPoppedUrl) {
this.lastPoppedUrl = undefined;
window.scrollTo(0, this.yScrollStack.pop());
} else
window.scrollTo(0, 0);
}
});
}
}
Event Timeline
Log In to Comment