我在这里遇到了一个非常奇怪的情况。
起初,我写了一个简单的指令。
mublABase.directive('parentSize', function() {
return {
link : function(scope, elem, attrs) {
scope.parentSize = {
width : elem.parent().width(),
height : elem.parent().height()
}
}
}
});
这是我的简化 html 代码
<input type="text" ng-model="parentSize.width"> //for test No.1
<div parent-size class="no-border">
{{parentSize.width}} //for test No.2
<span class="glyphicon glyphicon-leaf" ng-style="{'font-size':'{{parentSize.width}}px'}"></span> //this is the problem No.3
</div>
结果坏了。No.1 输入和 No.2 文本说宽度是 285。但是在 No.3,叶子图标的大小只是默认大小。
(抱歉没有发布结果图片。我在这里很菜鸟,我没有任何声誉)
怎么会发生?更重要的是,我该如何解决?