11import { CommonModule } from '@angular/common' ;
2- import { ChangeDetectionStrategy , Component , computed , signal } from '@angular/core' ;
2+ import { ChangeDetectionStrategy , Component , computed , inject , signal } from '@angular/core' ;
33import { FormsModule } from '@angular/forms' ;
44import { MonacoEditorModule , NGX_MONACO_EDITOR_CONFIG } from 'ngx-monaco-editor-v2' ;
55import { from } from 'rxjs' ;
66
77import { takeUntilDestroyed , toObservable } from '@angular/core/rxjs-interop' ;
8+ import { Meta , Title } from '@angular/platform-browser' ;
9+ import { getRouteData } from 'src/app/_services/route.service' ;
810import { MonacoEditorConfig } from 'src/app/monaco/monaco-global-config' ;
911import { MonacoConfig } from 'src/app/monaco/ng-monaco-config' ;
1012import { SwitchComponent } from '../../components/switch/switch.component' ;
@@ -59,6 +61,7 @@ import { EncoderServiceBase } from '../_services/encoder.service';
5961 changeDetection : ChangeDetectionStrategy . OnPush ,
6062} )
6163export class EncoderViewComponent {
64+ private convertService = inject ( EncoderServiceBase ) ;
6265 inputOptions : MonacoConfig ;
6366 outputOptions : MonacoConfig ;
6467
@@ -69,9 +72,16 @@ export class EncoderViewComponent {
6972 isEncode = signal < boolean > ( true ) ;
7073 modeLabel = computed ( ( ) => ( this . isEncode ( ) ? 'Encode' : 'Decode' ) ) ;
7174 title = '' ;
72-
73- constructor ( private convertService : EncoderServiceBase ) {
74- this . title = convertService . title ;
75+ private meta = inject ( Meta ) ;
76+ private titleService = inject ( Title ) ;
77+ constructor ( ) {
78+ var data = getRouteData ( this . convertService . routeName ) ;
79+ if ( ! data ) {
80+ throw new Error ( 'Route data not found for welcome' ) ;
81+ }
82+ this . titleService . setTitle ( 'UtilPlex |' + data . title ) ;
83+ if ( data . description ) this . meta . updateTag ( { name : 'description' , content : data . description } ) ;
84+ this . title = this . convertService . title ;
7585 toObservable ( this . isEncode )
7686 . pipe ( takeUntilDestroyed ( ) )
7787 . subscribe ( ( ) => {
@@ -87,7 +97,7 @@ export class EncoderViewComponent {
8797 language : '' ,
8898 readOnly : true ,
8999 } ;
90- convertService . optionsChanged . subscribe ( ( ) => {
100+ this . convertService . optionsChanged . subscribe ( ( ) => {
91101 this . inputChanged ( this . inputCode ( ) ) ;
92102 } ) ;
93103 }
0 commit comments