AngularJS is used to build single page web applications. So even if you change route i.e. route from one template to another, you would see the same title for all templates on the Browser.
In normal condition, route changes from a server, so page title set automatically to the title of head tag. Client-side routing doesn’t have that automatic mechanism.
Here is one of the simple way to change title of template on route.
Suppose, home.html and contact.html are two template files in template folder and index.html in root folder.
template/home.htmlThis is Home Page
This is Contact Page
Here in this example, we used ngBind instead of {{ expression }} for binding title when a template is momentarily displayed by the browser in its raw state before Angular compiles it.
Conclusion :
I hope that this article would have helped you in understanding to change title of page according to route in AngularJS Please share your knowledge if you know more about this attribute. Your feedback and constructive contributions are always welcome.
No comments:
Post a Comment