Let's take below as my MVC model class:
public class Candidate
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public int Experience { get; set; }
public List<Technology> Technologies { get; set; }
}
public class Technology
{
public string Technology { get; set; }
public int ExperinceInMonths { get; set; }
}
Now, I have a web api method which returns this modal data:
public class CandidateController : ApiController
{
// GET api/Candidate
public IEnumerable<Candidate> Get()
{
CandidateServiceClient client = new CandidateServiceClient();
List<Candidate> candidateData = client.GetCandidateData();
if (candidateData == null || candidateData.Count() == 0)
throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NoContent));
return candidateData.AsEnumerable();
}
...
Using Knockout let's say I have javascript something like this:
$.get(url, function (result) {
candidateViewModel.candidates(result);
ko.applyBindings(candidateViewModel);
});
});
var candidateViewModel = { candidates: ko.observableArray([])};
With this background, my question is how to construct knockout viewmodel which has nested collection(s) ? (like Technology collection in this example.)
Looking for something like..
var myViewModel = { firstName: ko.observable(''), lastName: ko.observable(''), .. };
Any help is greatly appreciated...