rawrstar
rawrstar

Reputation: 165

How to set title in html, from TS file ANGULAR

I want to display in my html page the title saying. "My name is " in which name value is coming form my query params

  queryParams() {
    this.route.queryParams.subscribe((param) => {
      this.firstName =param["first_name"];
     });
  }


title="My name is ${this.firstName} "

title is getting displayed, but not able to pass the value of first name in it

Upvotes: 0

Views: 780

Answers (1)

Mustahsan
Mustahsan

Reputation: 3862

try this:

queryParams() {
    this.route.queryParams.subscribe((param) => {
      this.firstName =param["first_name"];
      this.title = "My name is ${this.firstName} "
     });
}

Or you can display in your html like:

<div>My name is {{firstName}}</div>

Upvotes: 4

Related Questions