|
|
@@ -1,14 +1,17 @@
|
|
|
-import { Component } from '@angular/core';
|
|
|
-import { RouterModule, RouterOutlet } from '@angular/router';
|
|
|
+import { Component, OnInit } from '@angular/core';
|
|
|
+import { Router, RouterModule, RouterOutlet, RoutesRecognized } from '@angular/router';
|
|
|
import { MatModule } from '../dependencies/angularlib/mat.module';
|
|
|
import { DialogModule } from 'angularlib/dialog/dialog.module';
|
|
|
import { DialogUtil } from 'angularlib/dialog/dialog.util';
|
|
|
-import { NgxsModule } from '@ngxs/store'
|
|
|
+import { NgxsModule, Store } from '@ngxs/store'
|
|
|
import { LabelState } from 'angularlib/labels/label.state';
|
|
|
import { HttpClientModule } from '@angular/common/http';
|
|
|
import { Angularlib } from 'angularlib/angularlib.module';
|
|
|
import { CommonModule } from '@angular/common';
|
|
|
import { LabelModule } from 'angularlib/labels/label.module';
|
|
|
+import { BaseComponent, untilDestroy } from 'angularlib/base.component';
|
|
|
+import { filter, map } from 'rxjs';
|
|
|
+import { Title } from '@angular/platform-browser';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-root',
|
|
|
@@ -21,18 +24,31 @@ import { LabelModule } from 'angularlib/labels/label.module';
|
|
|
],
|
|
|
templateUrl: './app.component.html',
|
|
|
styleUrls: [
|
|
|
- './app.component.scss', './ng-sample.scss'
|
|
|
+ './app.component.scss'
|
|
|
]
|
|
|
})
|
|
|
-export class AppComponent {
|
|
|
- title = 'ng-template';
|
|
|
+export class AppComponent extends BaseComponent implements OnInit {
|
|
|
+ title = 'SwOPT Angular';
|
|
|
|
|
|
- constructor(private dialog: DialogUtil) {}
|
|
|
+ constructor(
|
|
|
+ private router: Router,
|
|
|
+ private store: Store,
|
|
|
+ /**Platform Browser title */
|
|
|
+ protected pbTitle: Title,
|
|
|
+ ) {
|
|
|
+ super(store);
|
|
|
+ }
|
|
|
|
|
|
- showDialog() {
|
|
|
- this.dialog.showDialog({
|
|
|
- title: 'test dialog',
|
|
|
- content: 'test dialog content'
|
|
|
+ ngOnInit(): void {
|
|
|
+ this.router.events.pipe(untilDestroy(this),
|
|
|
+ filter((event) => event instanceof RoutesRecognized),
|
|
|
+ map((res:any) => {
|
|
|
+ const data = res.state.root.firstChild.firstChild || res.state.root.firstChild;
|
|
|
+ return data.data?.title;
|
|
|
})
|
|
|
+ ).subscribe(title => {
|
|
|
+ this.title = title;
|
|
|
+ this.pbTitle.setTitle(this.title);
|
|
|
+ });
|
|
|
}
|
|
|
}
|