Implement two-way data binding for custom property

后端 未结 4 440
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-12 13:29

I see in primeng components the use something like ngModel (two-way data binding) style for some property like this

[(selection)]=\"selectedItem\";
<         


        
4条回答
  •  心在旅途
    2021-01-12 13:59

    In your child component (component-a) you need an @output

    @Output() change:EventEmitter = new EventEmitter();
    

    and then you notify parent component about a changed value by

    change.emit(newValue);
    

    See also Angular2: https://stackoverflow.com/a/33220997/3710630

提交回复
热议问题