0
私は非常に単純な指令を持っています。これは、ぼかしの入力値を更新するはずです。ng-metadata @Directive:入力値の設定方法は?
ブラーハンドラが呼び出されていますが、入力値を設定できません。
import {NgModel} from 'ng-metadata/common';
import {Directive, Inject, Self, HostListener} from 'ng-metadata/core';
@Directive({
selector: 'foo'
})
export class FooDirective {
constructor(
private @Self() ngModel: NgModel,
private @Inject('$element') $element: ng.IAugmentedJQuery
) {}
@HostListener('blur')
onBlur() {
this.ngModel.$viewValue = "FOO";
this.ngModel.$modelValue = "FOO";
this.ngModel.$setViewValue("FOO");
this.ngModel.$commitViewValue();
// I guess, I just need one of these, but none did work
}
}
HTMLコード:
<input type="text" foo ng-model="$ctrl.abc"></input>
私はconsole.log(this.ngModel.$modelValue)
を使用して現在の値を読むことができますが、私は新しい値を設定することはできませんよ。
私は何を欠場しましたか?