Saurabh
Saurabh

Reputation: 77

how to access property in a observable

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..

Upvotes: 1

Views: 199

Answers (1)

John Earles
John Earles

Reputation: 7194

You can access object properties by name using array semantics. Try this:

self.selectedCeremonyToUpdate()[name]()

Upvotes: 1

Related Questions