I have a requirement where I need to find an element in the dom which is mapped to a particular model property. I need to search the dom and use the model property name.
<input type="text" ng-model="vm.MyProperty" />
Now I would like to know how can I select the above element from dom if I know that I am looking for an element that is bound to the DOM using the property name 'vm.MyProperty'.
Some more clarification:
My initial form is rendered using angularjs and bound to a viewmodel/model the model looks like this
{
Name: "something",
Age: 45,
Address: {
Street: "123 somestreet",
Postcode: "ABC123",
Suburb: "Sometown"
}
}
My client after rendering the form shall call off to a config API which returns me this JSON object
{ Age: "readonly", "Address.Suburb": "hidden" }
I need the config object to contain any number of key value pairs, iterate through it and then find the corresponding dom field that is bound to they model property represented by the key, and apply either ng-readonly or ng-hidden to it accordingly.
I was looking for a way of how to find each dom element using the keys in teh config object.
Hope i am clear? Is there a smart way of relating the 2 model objects using a common key rather than plain strings? }