Why should we add “shim” for AngularJS when using Require.js?

In computer programming, a shim is a small library that transparently intercepts API calls and changes the arguments passed, handles the operation itself, or redirects the operation elsewhere.Shims typically come about when the behavior of an API changes, thereby causing compatibility issues for older applications that still rely on the older functionality. In these cases, the older API can still be supported by a thin compatibility layer on top of the newer code. Shims can also be used to run programs on different software platforms than they were developed for.


When using require.js, we usually write as follows. Continue reading “Why should we add “shim” for AngularJS when using Require.js?”

Resetting sorting in ng-grid

Applying sorting to an ng-grid is like a cake walk in Angular JS. But it is little tricky if you want to show the ng-grid with default data (the order in which it loaded first). Here is a solution for it.
Here I am taking a dropdown to change the sort order of the grid. So, I will be using ng-change of the dropdown to update the sort order in ng-grid.

<select ng-change="changeSortOrder" ng-model="empSortCol">
<option>Default Order</option>
<div ng-grid="myGrid"></div>

Here is the changeSortOrder function.

$scope.changeSortOrder = function() {
      if($scope.empSortCol == 'Default Order') {
           // reset sortInfo
           $scope.myGrid.ngGrid.config.sortInfo = { columns:[], fields: [''], directions: []};
      else {

If you are using external sorting, you can do it by clearing the lastSortedColumns.

angular.forEach($scope.myGrid.ngGrid.lastSortedColumns, function (c) {
      c.sortPriority = null;
      c.sortDirection = "";
  $scope.myGrid.ngGrid.lastSortedColumns = [];