Skip to content

Instantly share code, notes, and snippets.

@colinmacdonald
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colinmacdonald/11261078 to your computer and use it in GitHub Desktop.
Save colinmacdonald/11261078 to your computer and use it in GitHub Desktop.
Basic usage of $goQuery to order items by $$index with the keyFilter.
var app = angular.module('app', ['goangular']);
app.config(function($goConnectionProvider) {
var url = window.connectUrl || 'https://goinstant.net/account/app';
$goConnectionProvider.$set(url);
});
app.controller('queryCtrl', function($scope, $goQuery) {
$scope.data = $goQuery('myData', { sort: { '$name': 'desc'} }).$sync();
$scope.add = function() {
$scope.data.$add({ text: 'item' });
};
});
<body ng-app="app">
<div ng-controller="queryCtrl">
<button ng-click="add()">Add</button>
<ul>
<li ng-repeat="item in data | keyFilter">{{item.text}} - {{item.$name}}</li>
</ul>
</div>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment