N
N
nekritik2019-10-24 20:47:12
JavaScript
nekritik, 2019-10-24 20:47:12

Angular. How to call a function from a template on page load?

The question is quite simple. I change page title from template like this

<a (click)="mySetTitle( 'my new title' )">set title</a>.

I need mySetTitle to be executed on page load.

I tried this code but it doesn't work.
<div (load)="mySetTitle( 'my new title' )"></div>.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2019-10-24
@Xuxicheta

you seem to need this https://angular.io/guide/lifecycle-hooks

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question