dsfdfd1211 2016-10-28 09:15
浏览 51

使用angularjs获取laravel中的数据

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?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题