Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to have double array in Angularjs form?
    primarykey
    data
    text
    <p>I've recently been using Angularjs in my project. I'm trying to create a dynamic form which enables users to create crossword puzzle questions. I was thinking of using angularjs to allow users to add additional rows and columns into their answers. In my form, I've created an input called "answer" which has 2 child element row and column, and "column" has it's own child element as well. This is what I have done so far:</p> <p>html page:</p> <pre><code>Answer for the question: [&lt;a href='' ng:click='form.answer.$add()'&gt;AddRow&lt;/a&gt;] &lt;table&gt; &lt;div ng:repeat='ans in form.answer'&gt; &lt;tr&gt; &lt;td&gt;{{ans.row}}&lt;/td&gt; &lt;div ng:repeat='col in ans.column'&gt; &lt;td&gt;&lt;input type='text' name="col.word" ng:required/&gt;&lt;/td&gt; &lt;/div&gt; [&lt;a href='' ng:click='col.$add()'&gt;AddCol&lt;/a&gt;] &lt;/tr&gt; &lt;/div&gt; &lt;/table&gt; </code></pre> <p>javascript:</p> <pre><code>questionCtrl.$inject = ['$invalidWidgets']; function questionCtrl($invalidWidgets) { this.$invalidWidgets = $invalidWidgets; this.master = { title: 'title', descr:'description here', answer: [{row:'1', column:[{word:'z'},{word:'x'}]} ,{row:'2', column:[{word:'a'},{word:'w'}]} ], user:'' }; this.cancel(); } questionCtrl.prototype = { cancel : function(){ this.form = angular.copy(this.master); }, save: function(){ this.master = this.form; this.cancel(); } }; </code></pre> <p>I've manage to allow users to add rows to their answers, but I can't display the column array's element's at all. Is this because there is sonething wrong with my codes or Angularjs does not allow double arrays in their forms? Sorry if my explanation isn't clear.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload