我有从外部API调用返回的HTML字符串。我想编译该HTML字符串并通过id'test-input'获得一个已编译的htmlElement。从DOM获取元素时,我总是得到null或未定义。我正在使用p3x-angular-compile plugin的库:
我使用了ElementRef并在nativeElement
上尝试使用querySelector。仍然为空。
this.template = '<div id="test-input"><input type="text"></div>';
期望的是,一旦渲染并编译了此模板,我需要该元素以继续进行其他操作。