我需要在ngFor循环中创建唯一的锚点名称/组件,以将其与ComponentResolver.resolveComponent一起使用.
<div>
<table>
<tr *ng-for="#vIndex of vArr">
<td *ng-for="#hIndex of hArr">
<div #uniqueanchorname{{vIndex}}_{{hIndex}}></div>
</td>
</tr>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
生成的HTML应该看起来像这样:
<div>
<table>
<tr>
<td>
<div #uniqueanchorname0_0></div>
</td>
<td>
<div #uniqueanchorname0_1></div>
</td>
</tr>
<tr>
<td>
<div #uniqueanchorname1_0></div>
</td>
<td>
<div #uniqueanchorname1_1></div>
</td>
<td>
<div #uniqueanchorname1_2></div>
</td>
</tr>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
有了它,我可以使用DynamicComponentLoader,如:
loader.loadIntoLocation(responseDependentComponent, elementRef, 'uniqueAnchorName1_2');
Run Code Online (Sandbox Code Playgroud)
生成的HTML不会被替换,看起来像:
<div>
<table>
<tr>
<td>
<div #uniqueanchorname{{vIndex}}_{{hIndex}}></div>
</td>
<td>
<div #uniqueanchorname{{vIndex}}_{{hIndex}}></div>
</td>
</tr>
<tr>
<td>
<div #uniqueanchorname{{vIndex}}_{{hIndex}}></div>
</td>
<td>
<div #uniqueanchorname{{vIndex}}_{{hIndex}}></div>
</td>
<td>
<div #uniqueanchorname{{vIndex}}_{{hIndex}}></div>
</td>
</tr>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
如果无法创建唯一的锚名称.还有其他方法可以将组件加载到特定位置吗?
我正在尝试进行颤振驱动器集成测试。
使用
await driver.tap(longPressButtonFinder);
Run Code Online (Sandbox Code Playgroud)
没有帮助,还有什么比这更好的了吗?