在我的angularjs应用程序中,当我使用浏览器的后退按钮导航到上一页时。我的应用程序的标题不会切换回去。
我没有处理此问题,因为我认为这将在页面加载时得到解决。
该应用程序很大,因此没有任何特定的代码。问题出在整个应用程序中。
无论我是使用应用程序中的按钮还是通过浏览器的后退按钮进行导航,我都希望标题更改回上一页。
答案 0 :(得分:1)
您必须将其绑定到控制器中的数据,然后使用代码进行更改
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
<meta http-equiv="Content-language" content="en"/>
<!-- other stuff -->
<!-- dynamic data -->
<meta name="description" content="{{htmlDescription}}">
<link rel="shortcut icon" type="image/x-icon" ng-href="{{htmlFavIcon}}"/>
<title ng-bind="htmlTitle"></title>
当您从ctrlB击回按钮时,应触发先前的控制器(我们称其为ctrlA)逻辑。 ctrlA内部:
$rootScope.htmlTitle = ' title of screen A';
$rootScope.htmlDescription = ' html desc of screen A';