简体   繁体   中英

directive change ngmodel input value from contexmenu

i create a directive that display a custom context menu and when i select an item, the value binds to the input, the problem is that value is displayed but the ([ngModel]) not changed and after save nothing is updated. so how can i change the ngModel? thank you

the one way that worked for me is:

const ctrl = this.ngControl.control;
ctrl.setValue(this.elementRef.nativeElement.value);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM