2016-08-21 2 views
0

laravel 5/angular 1 어플리케이션에서 작업 중입니다! 내 응용 프로그램에서 데이터베이스 정보를 사용하고 싶었지만 뷰에서 json 형식으로 가져 왔습니다! 나는 그 결과 그것은 내 잘못이 다음각도로 그래픽 API 사용하기

[{"id":1,"title":"Title1","description":"descriptionk,","type":"opel","status":0,"user_id":0,"created_at":"2016-08-20 21:41:00","updated_at":"2016-08-20 21:41:00"},{"id":2,"title":"Title1","description":"descriptionk,","type":"opel","status":0,"user_id":0,"created_at":"2016-08-20 21:44:05","updated_at":"2016-08-20 21:44:05"},{"id":3,"title":"Title1","description":"descriptionk,","type":"opel","status":0,"user_id":0,"created_at":"2016-08-20 21:51:54","updated_at":"2016-08-20 21:51:54"},{"id":4,"title":"Im stuck in the elevator","description":"the elevator stoped in the fourth floor when I was getting to the second floor, please help me","type":"other things","status":0,"user_id":0,"created_at":"2016-08-21 15:06:41","updated_at":"2016-08-21 15:06:41"},{"id":5,"title":"Im stuck in the elevator","description":"the elevator stoped in the fourth floor when I was getting to the second floor, please help me","type":"other things","status":0,"user_id":0,"created_at":"2016-08-21 15:08:34","updated_at":"2016-08-21 15:08:34"}] 

답변

0

이었다처럼 무엇을 얻을 내 laravel보기

<div class="container" ng-app="alerts" ng-controller="alertscontroller"> 
<div class="col-sm-3" ng-repeat="alert in alerts"> 
    <div class="thumbnail"> 
    <div class="caption"> 
    <h3>User X</h3> 
    <p><strong>Title : </strong>@{{ alert.title }}</p> 
    <p><strong>Type : </strong>@{{ alert.type }}</p> 
    <p><strong>Description : </strong>@{{ alert.description }}</p> 
    </div> 
    </div> 
</div> 

됩니다

angular 
.module('alerts') 
.controller('alertscontroller', function($scope,$http){ 
$scope.alerts = []; 
$http.get('{{ url('resident.alerts') }}').success(function ($data) { 
       $scope.alerts = $data; 
          }); 
}); 

과 여기 : 다음은 각 컨트롤러의 ! routes 섹션에서 나는 다음을 가졌습니다 : Route::get('resident.alerts', ['uses'=>[email protected]', 'as'=>'resident.alerts']); 그리고 alertsControllers의 index 메소드는 경고를 리턴합니다 (Alert :: all() 반환)! 그것이 내가 얻은 결과 뒤에있는 이유입니다!