javascript - Creating AngularJS directive for editing key/value pairs with separate data definition -


i trying write directive editing array of data definition not known beforehand. there 2 pieces data, first there definition data structure loaded when page loads , looks this:

[     { 'name': 'first field',         'type: 'string',         'required': true,         'default': 'x'     },     { 'name': 'second field',         'type': 'list',         'values': ['one', 'two', 'three' ],     }     ... , on ] 

and then, when user edits data, use $http load data structure server looks this:

{     'not': 'important',     'blah': 'blah',     ...     'customfields': [          {              name:'first field',             value: 'a value'         },         {              name:'second field',             value: 'one'         }     ] } 

to make things worse, name/value pairs in customfields structure not guaranteed in same order definition, , might subset of defined fields (in case want show default value if present) ideally, i'd create angularjs directive can add

<fieldeditor field='customfields' /> 

to page , flesh out html needed. have gotten point directive looks definition , creates html template, i'm @ loss how hook data. possible add hooks directive can call 1 function each field when data being rendered , function when user modifies it? unfortunately, can not in postlink gets called before $http data loadded


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -