angular.js - angular2 encapsulating radio not working
黄舟
黄舟 2017-05-15 17:08:09
0
1
570

Parent component call

<x-radio [(M)]="sex" value="male">男</x-radio>
<x-radio [(M)]="sex" value="female">女</x-radio>

Subcomponent

<input type="radio" [ngModel]="M" (ngModelChange)="MChange.emit(value)" [attr.value]="value">

Writing like this now doesn’t work at all. If you don’t use subcomponents, there is no problem, but you need to encapsulate the style of the control. Please help - -

There is no problem with data changes in this writing method, but the selection effect will not be achieved.

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
PHPzhong

Solved, around the corner.

<input (change)="MChange.emit(value)" [attr.value]="value" [attr.checked]="M === value">
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template