Ich habe img-pop-Komponente erstellt, die @Input()
Bind-Eigenschaft src hat. Ich habe authSrc Direktive erstellt, die @HostBinding()
Eigenschaft src hat.Apply-Attribut-Direktive auf Komponente in Angular 4
@Component({
selector: 'img-pop',
template: `<img [src]="src"/>
<div *ngIf="isShow">
<----extra value----->
</div>`
})
export class ImgPopOverComponent implements OnInit {
@Input()
private src;
private isShow=false;
@HostListener('mouseenter') onMouseEnter() {
this.isShow= true;
}
@HostListener('mouseleave') onMouseLeave() {
this.isShow= false;
}
}
Ich habe Anweisung wie folgt.
@Directive({ selector: '[authSrc]' })
export class AuthSrcDirective implements OnInit {
@HostBinding()
private src: string;
constructor(private element: ElementRef) { }
ngOnInit() { }
@Input()
set authSrc(src) {
this.src = src+"?access_token=<-token->";
}
}
Ich möchte beide Funktionen in einem wie kombinieren.
<img-pop [authSrc]="/api/url/to/image"></img-pop>
so dass die endgültige URL-Aufruf wird/api/url/to/Bild access_token = < --token ->
aber es wirft Can't bind to 'src' since it isn't a known property of 'img-pop'.
Fehler
Bitte korrigieren Sie mich, wenn ich falsch mit konzeptionell bin.
Vielen Dank.
Bitte beachten Sie [meine Antwort] akzeptieren (https://Stackoverflow.com/a/44099557/2545680), wenn es geholfen hat –