如何以可观察的方式访问属性
问题描述:
我要访问"selectedCeremonyToUpdate()"中的可观察属性,该属性名称在名称"中.如果名称"包含城市",那么我要
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());
}
如何执行此操作..
答
您可以使用数组语义按名称访问对象属性.试试这个:
You can access object properties by name using array semantics. Try this:
self.selectedCeremonyToUpdate()[name]()