我遇到了一个似乎只出现在Safari中的角度问题:
TL; DR - 这是我在下面描述的一个明显的例子(显然,只有在野生动物园中运行插件才能证明这一点) https://plnkr.co/edit/t6Ts2DlhV84C7CLFzdui?p=preview
<html>
<head>
<script src="https://code.angularjs.org/1.6.6/angular.js"></script>
<script>
var app = angular.module('safariBug', []);
app.controller('main', function($scope) {
$scope.mytext = "Here is a bunch of text, some of which will continue to be displayed.";
$scope.update = function() {
$scope.mytext = "New line of text.";
}
});
</script>
</head>
<body ng-app='safariBug'>
<div ng-controller='main'>
<div style='height:300px;width:300px;font-size:48px'>{{mytext}}</div>
<input type='button' ng-click='update()' value='Update Text' />
</div>
</body>
</html>
使用数据绑定变量在视图中显示字符串时,请将字符串替换为立即显示的新值,但如果旧值较长则不会被删除。例如,如果字符串是&#34;原始句子&#34;,并且用#34;新文本&#34;替换它,它将最终显示诸如&#34;新的文本句子&#34;之类的内容。一旦html元素的样式被修改,它似乎迫使Safari在删除旧文本的情况下正确地重新呈现元素。
答案 0 :(得分:1)
<div style='height:300px;width:300px;font-size:48px' ng-bind="mytext"</div>
试试这种方式。