ElementRef
backToTopTargetを.back-to-top
に渡します。しかし、私はngOnChanges
ローカル変数をディレクティブに入力として渡します
<section #backToTopTarget>
<section class="back-to-top" [target]="backToTopTarget">
Back to top <i class="fa fa-angle-up"></i>
</section>
</section>
/// <reference path="../../../typings/angular2.d.ts" />
import {Directive, Input, OnChanges, ElementRef} from 'angular2/core';
import {BaseComponent} from "../../BaseComponent/BaseComponent";
@Directive({
selector: '.back-to-top',
})
export class BackToTop implements OnChanges {
private $el;
@Input('target') private target;
private $target;
constructor(private el: ElementRef) {
this.$el = $(this.el.nativeElement);
}
ngOnChanges({target}) {
// target.currentValue === undefined
}
}
だから私は何も私はそれが間違ってやっているではないか、できてそれを得ることができませんか?
ありません一つだけの引数があり、JSONは以下の通りです: '{ "ターゲット":{ "previousValue":{}}}' – tom10271
確認して実装してください。 'args'の中に' target'の値があることを確信しています。 – micronyks
'backToTopTarget'のデフォルト値はありますか?何がうまくいくのでしょうか? – micronyks