5

[AngularJS] Set HTML Document Title

 2 years ago
source link: https://siongui.github.io/2013/03/08/angularjs-set-html-document-title/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

[AngularJS] Set HTML Document Title

March 08, 2013

In pure JavaScript, the following way can be used to set HTML document title:

document.title = "myTitle";

However, this is not Angular way of doing programming, AngularJS provide $document for programmers to deal with HTML document. So I use the following syntax to set HTML document title:

$document.title = "myTitle"; // this doesn't work

But it does not work. Finally I found the correct way to set HTML document:

$document.prop('title', 'myTitle');

For those who has the same problem as me.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK