JSFiddle - React, Tailwind, and code Playground

by CharlesLin

HTML

<div data-bind="foreach: emps">
    <input type="radio" name="xxx" data-bind="value: Id, checked: $root.selectedEmpId" />
    <label data-bind="text: Name"></label>
  </div>
  <pre data-bind="text: ko.toJSON($root, null, 2)"></pre>

JavaScript

var Emp = function(data) {
    this.Id = ko.observable(data.Id);
    this.Name = ko.observable(data.Name);
};

var ViewModel = function() {

    this.emps = ko.observableArray([
        new Emp({
        Id: 1,
        Name: "Charles1"
    }),
        new Emp({
        Id: 2,
        Name: "Charles2"
    })
        ]);
    this.selectedEmpId = ko.observable();
};

var vm = new ViewModel();
vm.selectedEmpId(2);
ko.applyBindings(vm);