我正在尝试创建一个NgComponent
,在加载组件时会填充元素。如何知道组件何时填充模板?以下是我的一些代码:
class SleepTimeModule extends Module {
SleepTimeModule() {
//...
type(SleepGraph);
//...
}
}
//...
@NgComponent(
selector: 'sleep-graph',
publishAs: 'sleepGraph',
template: '<div><svg></svg></div>'
)
class SleepGraph {
Element element;
Scope scope;
@NgTwoWay('data')
var data;
SleepGraph(this.element, this.scope);
// when can I call this method?
// it modifies the dom
drawChart(data){
js.context.callMethod("drawChart", [
element.shadowRoot.querySelector("svg"),
new js.JsObject.jsify(data)
]);
}
}
答案 0 :(得分:0)
实施NgShadowRootAware
的{{1}}方法,如下所示:
onShadowRoot
已经有类似的问题: