Click here to Skip to main content
15,883,957 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi guys,

I am using angular grid. The way it is described in the below url tutorial every thing works fine for me.
http://angular-ui.github.io/ng-grid/[^

HTML code:
XML
<body ng-app="">
    <div data-ng-controller="BindNgGrid">
    <p>{{name}}</p>
  <div class="gridStyle" ng-grid="gridOptions"></div>
  </div>
</body>


Javascript:

PHP
function BindNgGrid($scope) {
    $scope.name='XXX YYY ZZZ'
    $scope.myData = [{ name: "Moroni1", age: 50 },
                    { name: "Tiancum1", age: 43 },
                    { name: "Jacob1", age: 27 },
                    { name: "Nephi1", age: 29 },
                    { name: "Enos1", age: 34 }];
    $scope.gridOptions = { data: 'myData' };
}


now in my above code
$scope.name<pre> gets resolved but grid options data is not getting populated any one have any idea where i am going wrong.
Posted
Updated 12-Jan-17 2:00am
v2
Comments
pankaj287 18-Feb-17 12:36pm    
You missed to inject `ngGrid` module inside your app dependency, & do inject your `app` to `ng-app` directive, refer https://angular-ui.github.io/ui-grid/ for reference. It has been well document

1 solution

HTML
//In HTML 

HTML
<body ng-app="demoApp">
    <div data-ng-controller="BindNgGrid">
    <p>{{name}}</p>
  <div class="gridStyle" ng-grid="gridOptions"></div>
  </div>
</body>



JavaScript
//in js File please inject the ngGrid
var app = angular.module('demoApp', ['ngGrid']);
function BindNgGrid($scope) {
  $scope.name='XXX YYY ZZZ';
    $scope.myData = [{name: "Moroni", age: 50},
                     {name: "Tiancum", age: 43},
                     {name: "Jacob", age: 27},
                     {name: "Nephi", age: 29},
                     {name: "Enos", age: 34}];
    $scope.gridOptions = { data: 'myData' };
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900