0.1.26 • Published 5 years ago
@acknow-srl/title v0.1.26
Title
Allows you to configure a common title, with and optional variabile part, for your apps.
AckTitleModule (Module)
Methods
- forRoot(config: AckTitleConfig): void: configures the format for the title.
AckTitleConfig (Interface)
- format (string): Title format. You can use
{{TITLE}}
placeholder to change the title variable part based on the page/route.
AckTitle (Service)
It is provided in root, so it is available to the whole app.
Methods
- get(): string: Returns the title.
- set(title: string): void: Sets the title variable part, according to the configured format.
Example
/**
* 1. Import the module and the configuration model in your main module (usually app.module.ts).
*/
import { AckTitleModule, AckTitleConfig } from '@acknow-srl/title';
/**
* 2. Add the module to your app imports and configure it.
*/
// By using this format, {{TITLE}} will be the title variable part. Any component can override it using AckTitle.set() method.
const config: AckTitleConfig = {format: '{{TITLE}} - My app name'};
@NgModule({
declarations: [
AppComponent
...
],
imports: [
...
AckTitleModule.forRoot(config),
...
],
bootstrap: [AppComponent]
})
export class AppModule {
}
/**
* 3. Implement AckTitle service in your components.
*/
import { Component, OnInit } from '@angular/core';
import { AckTitle } from '@acknow-srl/title';
@Component({
selector: 'my-component',
templateUrl: 'my-component.html',
styleUrls: ['my-component.css']
})
export class MyComponent implements OnInit {
constructor(private _title: AckTitle) {
}
ngOnInit() {
// The content for the HTML <title> tag will be: 'My component title - My app name'.
this._title.set('My component title');
}
}
0.1.26
5 years ago
0.0.26
5 years ago
0.0.25
5 years ago
0.0.24
5 years ago
0.0.23
5 years ago
0.0.22
5 years ago
0.0.21
5 years ago
0.0.20
5 years ago
0.0.18
5 years ago
0.0.17
5 years ago
0.0.16
5 years ago
0.0.15
5 years ago
0.0.14
5 years ago
0.0.13
5 years ago
0.0.12
5 years ago
0.0.11
5 years ago
0.0.10
5 years ago
0.0.9
5 years ago
0.0.8
5 years ago
0.0.7
5 years ago
0.0.6
5 years ago
0.0.5
5 years ago
0.0.4
5 years ago
0.0.3
5 years ago
0.0.2
5 years ago
0.0.1
5 years ago