【发布时间】:2017-11-10 08:43:35
【问题描述】:
我有一个 HTML 跨度,它有两个超链接。
<span><a href="http://appcarvers.cloudaccess.host/index.php?Itemid=207" alt="Shirley Setia">Shirley Setia</a><i class="fa fa-caret-right"></i>
<a href="http://appcarvers.cloudaccess.host/index.php?Itemid=210" alt="Harry">Harry</a>
</span>
import { Directive, ElementRef, Renderer, HostListener } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Input, Output, EventEmitter } from '@angular/core';
@Directive({
selector: '[stream-link]' // Attribute selector
})
export class StreamLink {
constructor(public element: ElementRef, public renderer: Renderer) {
renderer.listen(element.nativeElement, 'click', (event) => {
let anchorUrl = this.element.nativeElement.querySelector('a');
// This anchorUrl shows only first href url
}
}
}
【问题讨论】:
-
尝试使用@ContentChildren
标签: angular ionic2 angular2-directives