mardi 25 février 2020

How to pass array result to angular grid

this is the example script of angular grid,in my laravel blade

angular.module('app', ['ngTouch', 'ui.grid'])
.controller('MainCtrl', MainCtrl);

function MainCtrl() {
  this.myData = [
    {
        firstName: "Cox",
        lastName: "Carney",
        company: "Enormo",
        employed: true
    },
    {
        firstName: "Lorraine",
        lastName: "Wise",
        company: "Comveyer",
        employed: false
    },
    {
        firstName: "Nancy",
        lastName: "Waters",
        company: "Fuelton",
        employed: false
    }
  ];
}

its looks like below. enter image description here

I want to pass my query result to this table and display with corresponding columns.

controller

$userObjs = works::getWorksFull();
return view('admin.works.full_assign',['userObjs'=>$userObjs]);

Model works.php

public static function getWorksFull()
{ 
    $results = self::select('ID','Number','Name','Type','District','Segment','status')
    ->where('status','=',"Open" )       
    ->get();
    return $results;
}

My blade view

<html ng-app="app">
    <div ng-controller="MainCtrl as $ctrl">
        <div ng-controller="MainCtrl as $ctrl">
          <div id="grid1" ui-grid="{ data: $ctrl.myData }" class="grid"></div>
        </div>
    </div>    
</html>


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire