-
Notifications
You must be signed in to change notification settings - Fork 0
@bynary.composables.title
github-actions[bot] edited this page Nov 18, 2023
·
38 revisions
Composables for managing the title of the page.
▸ bindTitle<T
>(value
): T
Binds the value of the signal to the title of the page.
Name | Type |
---|---|
T |
extends Signal <string > |
Name | Type | Description |
---|---|---|
value |
T |
The signal to bind to the title. |
T
Example
@Component({
selector: 'my-component',
template: ''
})
class MyComponent {
name = signal('Jane');
constructor() {
bindTitle(computed(() => `Hello ${this.name()}`));
}
}
title/src/title.composable.ts:24
▸ useTitle(initialValue?
): WritableSignal
<string
>
A signal to change the title of the page.
Name | Type | Description |
---|---|---|
initialValue? |
string |
The initial title of the page. Defaults to the current title of the page. |
WritableSignal
<string
>
Example
@Component({
selector: 'my-component',
template: ''
})
class MyComponent {
title = useTitle('Hello World'); // The title of the page is now 'Hello World'
greetUser(name: string) {
this.title.set(`Hello ${name}`); // For a name 'Jane', the title of the page is now 'Hello Jane'
}
}
Example
Reading the current title of the page
@Component({
selector: 'my-component',
template: ''
})
class MyComponent {
title = useTitle(); // The initial value of the signal is the current title of the page
}