ng-bind
或者 ng-cloak
而非簡單的 {{ }}
以防止頁面渲染時的閃爍。<img>
的 src
時使用 ng-src
而非 src
中嵌套 {{}}
的模板。<a>
的 href
時使用 ng-href
而非 href
中嵌套 {{ }}
的模板。ng-style
指令,而非將 scope 變量作為字符串通過 {{ }}
用于 style
屬性。<script>
...
$scope.divStyle = {
width: 200,
position: 'relative'
};
...
</script>
<div ng-style="divStyle">my beautifully styled div which will work in IE</div>;
更多建議: