請參閱下面的附在<title>
標籤上的超簡單指令。在現代瀏覽器中,這激活並將標題更改爲「標題C」,但在IE8中,鏈接功能從未被調用,並且標題保持「標題B」。IE8中標題標籤上的屬性指令不運行
Angular中的<title>
標記是否通過跨瀏覽器方式支持指令屬性?我有更新標題值的其他解決方法,但我正在尋找一些關於Angular是否支持這個的明確性,或者爲什麼不。
<!doctype html>
<html xmlns:ng="http://angularjs.org" id="ng-app" ng-app="myApp">
<head>
<title update-title>Title A</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.js"></script>
</head>
<body>
body content
<script>
window.document.title = "title B";
angular.module('myApp', [])
.directive('updateTitle', ['$window', function($window) {
return {
restrict: 'A',
scope: { },
link: function(scope, element) {
$window.document.title = "title C";
}
};
}]);
</script>
</body>
</html>