title: ag-grid Cannot read property 'setRowData' because gridOptions.api undefined
body: <p>i have a ag-grid working in project. but now when i ported the same to another page i got some error .. i tried to avoid the http call in between and directly tried to set the ROW Data through   </p>
  
  <pre><code> $scope.gridOptions.api.setRowData(RowDatas);
  </code></pre>
  
  <p>but error is "TypeError: Cannot read property 'setRowData' of undefined"</p>
  
  <p>So n debug i realised api is Undefined . here is my complete code . please check what i missed ..</p>
  
  <p></p>
  
  <pre><code>&lt;head&gt;
  &lt;script src="js/angular_1_3_8.js"&gt;&lt;/script&gt;
  &lt;script src="js/angular-filter.js"&gt;&lt;/script&gt;
  &lt;script src="workbench/agGrid/dist/ag-grid.js?ignore=notused34"&gt;&lt;/script&gt;
  &lt;script&gt;
      agGrid.initialiseAgGridWithAngular1(angular);
      var app = angular.module("workbenchApp", ['angular.filter',"agGrid"]);
      app.controller("workBenchCtrl", function ($scope, $http, $filter) {
  
      var columnDefs = [
      {headerName: "Name", field: "Name"},
      {headerName: "Cr", field: "dc"},
      {headerName: "Ac", field: "da"},
      {headerName: "Mo", field: "dm"},
  
  ];
  
  var RowDatas=[{"Name": "SUHDLOG.DAT", "dc": "1970-01-01 05:30:00", "da": "2002-12-27 00:00:00", "dm": "2002-12-27 09:51:22"},
  { "Name": "BOOTLOG.PRV", "dc": "1970-01-01 05:30:00", "da": "2005-04-01 00:00:00", "dm": "2005-04-01 15:13:30"},
  { "Name": "FRUNLOG.TXT", "dc": "1970-01-01 05:30:00", "da": "2002-12-27 00:00:00", "dm": "2002-12-27 09:52:56"},
  { "Name": "COMMAND.COM", "dc": "1970-01-01 05:30:00", "da": "2002-12-27 00:00:00", "dm": "1999-04-23 22:22:00"},
  { "Name": "BOOTLOG.TXT", "dc": "1970-01-01 05:30:00", "da": "2005-04-02 00:00:00", "dm": "2005-04-02 14:38:00"},
  { "Name": "DETLOG.TXT", "dc": "1970-01-01 05:30:00", "da": "2002-12-28 00:00:00", "dm": "2002-12-28 09:56:02"},
  { "Name": "CONFIG.SYS", "dc": "1970-01-01 05:30:00", "da": "2005-06-16 00:00:00", "dm": "2003-07-03 18:39:50"},
  { "Name": "DBLSPACE.BIN", "dc": "1970-01-01 05:30:00", "da": "2002-12-27 00:00:00", "dm": "1999-04-23 22:22:00"},
  { "Name": "MSDOS.SYS", "dc": "1970-01-01 05:30:00", "da": "2003-07-03 00:00:00", "dm": "2002-12-27 10:01:58"},
  { "Name": "DRVSPACE.BIN", "dc": "1970-01-01 05:30:00", "da": "2002-12-27 00:00:00", "dm": "1999-04-23 22:22:00"},
  { "Name": "MSDOS.---", "dc": "1970-01-01 05:30:00", "da": "2002-12-27 00:00:00", "dm": "2002-12-27 09:46:28"},
  { "Name": "SETUPLOG.TXT", "dc": "1970-01-01 05:30:00", "da": "2002-12-27 00:00:00", "dm": "2002-12-27 10:04:12"},
  { "Name": "WSOCK32.DLL", "dc": "1970-01-01 05:30:00", "da": "2005-06-16 00:00:00", "dm": "2002-12-27 09:47:10"},
  { "Name": "CFGWIZ.DLL", "dc": "1970-01-01 05:30:00", "da": "2005-02-26 00:00:00", "dm": "2002-12-27 09:47:12"},
  ];
  
  $scope.gridOptions = {
          angularCompileHeaders: true,
          columnDefs: columnDefs,
          rowData:[{"Name": "SUHDLOG.DAT", "dc": "1970-01-01 05:30:00", "da": "2002-12-27 00:00:00", "dm": "2002-12-27 09:51:22"}]
                  };
  
      /*
      $http.get('FileList.json').success(function (response) {
      $scope.TData = response;
      DateArray=$scope.TData.Files;
      $scope.gridOptions.api.setRowData(DateArray);
  
  
      });
      */
      $scope.gridOptions.api.setRowData(RowDatas);
  
      });
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div ng-app="workbenchApp"&gt;
      &lt;div ng-controller="workBenchCtrl"&gt;
          &lt;div ag-grid="gridOptions" class="ag-blue" style="height: 500px;"&gt;&lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>