请参阅下面的附在<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>