Is there a way to dynamically update the title tag of my page based on the H1 tag in AngularJS?
In jQuery, I could achieve this by:
var title = $('#content').find('h1').first().text();
if (title.length >= 1)
{
document.title = 'My Site Name | ' + (title);
}
else {
document.title = 'My Site Name';
}
What would be the best approach to do the same in AngularJS?
I prefer not to include this in the app.js file as it doesn't feel right to mix content that may change with code. If I modify the text of the H1 in my partial view, I want the title to automatically update.