{"flag":true,"single":true,"pageTitle":"Angular | Set Page title dynamically based on API call","post":{"id":107,"user_id":"3","slug":"angular-set-page-title-dynamically-based-on-api-call-dd5r","title":"Angular | Set Page title dynamically based on API call","body":"<ol>\r\n<li>Import the <code>Title<\/code> service in your component:<\/li>\r\n<\/ol>\r\n<pre class=\"language-markup\"><code>import { Title } from '@angular\/platform-browser';<\/code><\/pre>\r\n<p>2. Inject the <code>Title<\/code> service in the constructor of your component:<\/p>\r\n<pre class=\"language-markup\"><code>constructor(private titleService: Title) {}<\/code><\/pre>\r\n<p>3. Set the page title using the setTitle method of the Title service in the subscribe callback:<\/p>\r\n<pre class=\"language-markup\"><code>this.pageTitle = data.PageTitle;\r\nthis.titleService.setTitle(this.pageTitle); \/\/ Set the page title dynamically<\/code><\/pre>\r\n<p>&nbsp;<\/p>\r\n<p>&nbsp;<\/p>","category_id":"14","is_private":"0","created_at":"2023-04-06T23:39:30.000000Z","updated_at":"2023-04-06T23:39:30.000000Z","category":{"id":14,"user_id":"3","name":"Angular","slug":"angular-gd2h","parent_id":null,"created_at":"2023-03-28T22:24:44.000000Z","updated_at":"2023-03-28T22:24:44.000000Z"},"user":{"id":3,"name":"Muhammad Farhan","email":"helpinghour@gmail.com","email_verified_at":null,"two_factor_confirmed_at":null,"current_team_id":"3","profile_photo_path":null,"created_at":"2023-03-28T22:23:15.000000Z","updated_at":"2023-03-28T22:24:06.000000Z","profile_photo_url":"https:\/\/ui-avatars.com\/api\/?name=M+F&color=7F9CF5&background=EBF4FF"}},"pageDesc":" Import the Title service in your component:  import { Title } from '@angular\/platform-browser'; 2. Inject the Title service in the construc - Angular | Set Page title dynamically based on API call (Updated: April 6, 2023) - Read more about Angular | Set Page title dynamically based on API call at my programming site [SITE]","categories":[]}