问题
I want to access the property in 'selectedCeremonyToUpdate()' observable whose property name is in 'name'. If 'name' contains 'City' then i want
self.edit = function (data, event, name) {
alert("In " + self.selectedCeremonyToUpdate().City());
}
how to do this..
回答1:
You can access object properties by name using array semantics. Try this:
self.selectedCeremonyToUpdate()[name]()
来源:https://stackoverflow.com/questions/14055594/how-to-access-property-in-a-observable