I am getting Error: Grid argument is not a Grid object
only in prod (its working in dev), after javascript minification.
I delved into the ui.grid's code, and my initial thought is that there is a bug but since no one seemed to complain I thought I am doing something wrong.
The reason I think its a bug caused by minification:
The error occurs here, where n in dev is a function of type 'Grid', but after being minified its of type 'h'
if ("Grid" !== t.type(n))
throw new Error("Grid argument is not a Grid object");
t.type gets the type of the function by using Function.prototype.toString. The type's name has been changed during minification, and will not equal "Grid" as the condition above demands
h.type = function(e) {
var t = Function.prototype.toString.call(e.constructor);
return t.match(/function (.*?)\(/)[1]
I am using Rails 4, latest version of angular and ui.grid.
Though I think it's irrelevant, here is my code:
View:
<div ng-controller="SummonersCtrl">
<p>
<strong>Name:</strong>
<span>{{summoner.name}}</span>
</p>
<p>
<strong>Region:</strong>
<span>{{summoner.region}}</span>
</p>
<div id="rune-statistics">
<h2>Runepage Usage</h2>
<p>Stats of {{summoner.sumOfGames()}} games.</p>
<div ui-grid="gridOptions" class="stats-grid"></div>
</div>
</div>
Ctrl:
runestats = angular.module('runestats')
summonersCtrl = runestats.controller 'SummonersCtrl'
, ['Summoner', 'backendApi', '$rootScope', '$scope', '$http', '$log'
, (Summoner, backendApi, $rootScope, $scope, $http, $log) ->
$scope.summoners = []
$scope.gridOptions =
data: 'summoner.total_runestats'
backendApi.getSummoners().success (data) ->
$scope.summoners = data
$rootScope.$on 'summonerSearched', (event, name, region) ->
backendApi.getSummoner(name, region).success (data) ->
$scope.summoner = new Summoner(data)
$rootScope.$broadcast('summonerFound', name, region)
]
Is this a bug, or am I doing something wrong?