MarsDB-Angular
MarsDB-Angular is an AngularJS 1.x binding for MarsDB. It makes easy to use MarsDB in an angular application by automatically wrap all returned promises with $q
and destroy observers on $scope's $destroy
event.
Examples
Include marsdb.angular.js
after marsdb.min.js
and angular.js
in your <head>
. Also don't forget to include marsdb.polyfills.js
. Then add a MarsDB
dependency in your module. That's it. Now you can use $collection
factory. For example:
angular.module(‘app’, [‘MarsDB’])
.controller(function($scope, $collection) {
const posts = $collection(‘posts’);
posts.find({authorId: 123}).observe((docs) => {
$scope.posts = docs;
}, $scope).then(() => {
$scope.loaded = true;
});
});
All included storage implementations is available in a Mars.Storages
global variable. You can set different default storage by $collectionProvider.defaultStorageManager(Mars.Storages.LocalForage)
.
You also can use MarsDB within browserify environment. Just require(‘marsdb-angular’)
and MarsDB module will be added to the angular. Angular must be defined in a window
or must be available as a module require(‘angular’)
.
Contributing
I’m waiting for your pull requests and issues.
Don’t forget to execute gulp lint
before requesting. Accepted only requests without errors.
License
See License