I've a simple question/answer app built on laravel. When a user adds a new question, the question gets displayed on the dashboard page.
Sample dashboard view-
Welcome John!
- This is first question
- This is second question
This is done using laravel only. Now I want to fetch and display answers under each question respectively using angular only, this way:
Welcome John!
- This is first question
-answer 1
-answer 2
- This is second question
-answer 1
-answer 2
Since all the answers part should be done using angularjs and that too on page load, how can I let angularjs know which answers to fetch and where to display
I tried the following approach using directives
@section('list-questions')
<ul>
@foreach($listQuestions as $q)
<li><a href="{{url('/questions/'.$q->question_id)}}">{{ $q->question }}</a></li>
<getAnswers ng-model="qid" ng-init="qid='{{$q->question_id}}'"></getAnswers>
@endforeach
</ul>
@endsection
I'm trying to get 'ID' of each question and then pass it to controller, use $http.get
and show it using directives, but I'm unable to pick the ng-model value, is there any other way or how should I fix this?