我在组件定义字符串列表,它的渲染鉴于这样的:访问elementRef在点击事件角
<span class="one" (click)='do($event, index, item)'
*ngFor="let item of result;let index = index" >{{item}} </span>
后的每个项目点击我希望该项目后添加div元素:
clickedSpan.insertAdjacentHTML('beforeend', '<div >Hi!</div>');
如何访问elementRef in do
函数?或者是否有其他解决方案来处理由ngFor渲染的渲染跨度?
'' - > https://angular.io/docs/ts/latest/guide/template-syntax.html#!#ref-vars –