javascript - Angularjs binding to JSON sets value to undefined -


i have tricky issue nested bindings in custom directives. have json structure looks bit this;

{  survey:     questions:[         {         text:'question 1',         answers:[             {             text:'answer 1'             },             ..                 ]         },         ...     ] } 

each survey has many questions , each question has many answers. have created directives forms survey , questions. question directives have nested answer directives. directives looped out , bound json. html looks this:

the page;

<div>     <survey-form></survey-form>     <div ng-repeat="question in survey.questions">          <question-form></question-form>     </div> </div> 

the question-form directive;

<div>      <h1>{{question.title}}</h1>      <div ng-repeat="answer in question.answers">           <answer-form></answer-form>      </div>  </div> 

this appears fine , no errors in console. seemingly random text attributes being set undefined in underlying json binding form inputs complete. if bind none editable elements expected. additionally not apply every element in nested json - see text values set undefined , others remain in source json.

can shed light on issue? annoying , think maybe bug in angular..

thanks in advance

could simple question.text instead of question.title? notice in json it's text. if it's not that, can provide directive information answers, , possibly set jsfiddle/plunkr show happenning.


Comments