44@description
55
66Angular-data is an in-browser data store for [Angular.js](http://angularjs.org).
7- [Synchronous methods](/documentation/guide/synchronous/index ) work only with data already in the data store, and
8- [asynchronous methods](/documentation/guide/asynchronous/index ) work with a persistence layer.
7+ [Synchronous methods](/documentation/guide/angular-data/synchronous ) work only with data already in the data store, and
8+ [Asynchronous methods](/documentation/guide/angular-data/asynchronous ) work with a persistence layer.
99
1010<p>
1111 <img src="/resources/img/chart.png" width="940">
@@ -15,7 +15,7 @@ Angular-data is an in-browser data store for [Angular.js](http://angularjs.org).
1515```js
1616angular.module('myApp', ['angular-data.DS'])
1717 .config(function (DSProvider) {
18- DSProvider.defaults.baseUrl = 'https://example.com /api';
18+ DSProvider.defaults.baseUrl = '/api';
1919 })
2020 .run(function (DS) {
2121 DS.defineResource({
@@ -25,16 +25,21 @@ angular.module('myApp', ['angular-data.DS'])
2525 });
2626 })
2727 .controller('PostCtrl', function ($scope, DS) {
28- var query = {
29- query: {
30- where: {
31- author: 'John Anderson'
32- }
33- }
34- };
28+ var params = {
29+ query: {
30+ where: {
31+ author: {
32+ '==': 'John Anderson'
33+ }
34+ }
35+ }
36+ };
3537
36- DS.findAll('post', query );
38+ DS.findAll('post', params );
3739
40+ DS.bindAll($scope', 'posts', 'post', params);
41+
42+ // Verbose way of doing the bindAll() above, but gives more control
3843 $scope.$watch(function () {
3944 return DS.lastModified('post');
4045 }, function () {
@@ -54,7 +59,7 @@ $scope.posts; // [{ id: 1, author: 'John Anderson', title: 'How to cook' },
5459
5560You define _resources_ and register them with the data store. A _resource definition_ tells angular-data
5661about a particular resource, like what its root endpoint is and which attribute refers to the primary key of the
57- resource. A _resource definition_ can also specify validation functions to be executed during model lifecycle operations.
62+ resource. A _resource definition_ can also specify functions to be executed during model lifecycle operations.
5863
5964```js
6065DS.defineResource({
@@ -71,7 +76,7 @@ DS.defineResource({
7176});
7277```
7378
74- `validate` will be executed at the beginning of the lifecycle initiated by a call to `DS.create` or `DS.save`.
79+ `validate` will be executed at the beginning of the lifecycle initiated by a calls to `DS.create`, `DS.save`, etc .
7580```js
7681DS.create('post', { author: 'Sally', title: 'Angular gotchas' })
7782 .then(function (post) {
0 commit comments