-
Notifications
You must be signed in to change notification settings - Fork 0
@bynary.composables.title
github-actions[bot] edited this page Nov 23, 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.
This composable currently does not listen for changes to the title of the page made by other means. It will only set the title of the page, not read it.
Name | Type |
---|---|
T |
extends Signal <string > |
Name | Type | Description |
---|---|---|
value |
T |
The signal to bind to the title. |
T
The passed in signal (value
parameter)
Example
@Component({
selector: 'my-component',
template: ''
})
class MyComponent {
name = signal('Jane');
constructor() {
bindTitle(computed(() => `Hello ${this.name()}`));
}
}
title/src/title.composable.ts:28
▸ useTitle(initialValue?
): WritableSignal
<string
>
A signal to change the title of the page.
This composable currently does not listen for changes to the title of the page made by other means. It will only set the title of the page, not read it.
Name | Type | Description |
---|---|---|
initialValue? |
string |
The initial title of the page. Defaults to the current title of the page. |
WritableSignal
<string
>
A signal to change the title of the page.
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
}