【发布时间】:2015-09-01 17:17:06
【问题描述】:
通过以下方式创建指令时,元素本身 (<a-directive>) 的高度为 0px,宽度为 0px。 jsfiddle
var myApp = angular.module('myApp', []).directive('aDirective', function () {
return {
template: '<div style="height:100px;width:100px;background-color:red;"></div>',
restrict: 'E',
link: function (scope, element, attrs) {
}
};
});
还有html:
<a-directive></a-directive>
如何让 html 元素拥有其子维度?
编辑:
我只是在小提琴中看到它有一个维度。但在我的项目中,它通常没有。任何想法为什么会出现这种情况?
【问题讨论】:
-
我想我找到了原因。模板中的有
position: absolute.
标签: css angularjs angularjs-directive