I'm new to AngularJS and somewhat of a JavaScript amateur as well.
I'm have a need to change the contents of a table cell based on the data in the model. My model includes some metadata about a piece of data, and I want to read the metadata and dynamically set the cell based on that data.
For example, if the metadata looks like "{ type: 'text', value: 'Foo' }" the contents of the cell should be a text input field, with the content of the field set to "Foo". If the user edits the cell, perhaps to set it to "Bar", I'd like to update the metadata accordingly (i.e., the new data looks like "{ type: 'text', value: 'Bar' }".
Likewise, if the metadata is "{ type: 'select', choices: ['A', 'B', 'C'], value: 'B' }" then I want the cell to contain a 'select' element with the values 'A', 'B', 'C' and the current selection of 'B', along with the appropriate angular data binding.
I'm having trouble figuring how to make this work. I have a plunker of this
here.
This almost works but the binding is not working.
Any suggestions on how to make this approach work, or a description of a better approach, is welcome!