how to access property in a observable

2019-08-03 02:47发布

问题:

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]()


标签: knockout.js