@beduin01

Как правильно реализовать вложенный цикл в AngularJS?

<div class="container" ng-controller="TestQuestions">
		<div id="row" ng-repeat="question in questions">
			<div ng-repeat="answer in question.answer">
					<p></p>
				<h4 class="page-header">{{question.id}}. {{question.question}}</h4>
				<p></p>
				<button type="button" class="btn btn-info" value="Input Button">{{answer}}</button>
			</div>
		</div>
	</div>



app.controller("TestQuestions", function($scope) 
	{
		$scope.questions =
		[
			{
				id: 1, question: "Sex?", "sex": {"m":"male", "f":"female"}
			},

			{
				id: 2, question: "Level of your organization", answer: ["Personal", "Federal", "Privat"]
			},

			{
				id: 3, question: "What is your name?", answer: ["Dima", "Roma", "Masha"]
			},
			{
				id: 4, question: "Where do you live?", answer: ["Moscow", "London", "Minsk"]
			}
		];
	} 

	);


Проблема в том, что данный цикл мне выводит в столбик:
2. Level of your organization
Personal
2. Level of your organization
Federal
2. Level of your organization
Privat

мне же нужно

2. Level of your organization
Personal Federal Privat
  • Вопрос задан
  • 571 просмотр
Решения вопроса 1
R0dger
@R0dger
Laravel/Yii/2 AngularJs PHP RESTful API
<div id="row" ng-repeat="question in questions">
        <h4 class="page-header">{{question.id}}. {{question.question}}</h4>
        <span ng-repeat="answer in question.answer">
            <button type="button" class="btn btn-info" value="Input Button">{{answer}}</button>
      </span>
    </div>
Ответ написан
Пригласить эксперта
Ответы на вопрос 1
AMar4enko
@AMar4enko
<div class="container" ng-controller="TestQuestions">
    <div id="row" ng-repeat="question in questions">
    <h4 class="page-header">{{question.id}}. {{question.question}}</h4>
      <div ng-repeat="answer in question.answer">
          <p></p>
        
        <p></p>
        <button type="button" class="btn btn-info" value="Input Button">{{answer}}</button>
      </div>
    </div>
  </div>


Computer Since, ага
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы