Skip to content

Angular Integration

Techfort edited this page Apr 20, 2015 · 1 revision

LokiJS can easily be integrated in angular by using lokiAngular.js, which is in the src/ folder.

assuming your app is called 'myApp', you would integrated LokiJS like so:

angular.module('myApp', ['lokijs'])
.controller(MyCtrl, ['$scope', 'Loki', function MyCtrl($scope, Loki) {
  $scope.db = new Loki('myDb');
  $scope.db.loadDatabase({}, loadHandler);
  function loadHandler() {
    $scope.users = $scope.db.getCollection('users');
    // your logic here ...
  }
}]);