Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Commit afe18b5

Browse files
committed
Support Angular 1.3 #97
* Upgrade version of angular-resource to 1.3.2 for documentation * Update documentation
1 parent 2cddcca commit afe18b5

9 files changed

+474
-304
lines changed

demo/basic/angularWay.html

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ <h1><i class="fa fa-play"></i>&nbsp;The Angular way</h1>
3030
If your DataTable has a lot of rows, I <strong>STRONGLY</strong> advice you to use the Ajax solutions.
3131
</p>
3232
</div>
33+
<div class="alert alert-info">
34+
<p>
35+
With Angular v1.3, the <a href="https://docs.angularjs.org/guide/expression#one-time-binding"><strong>one time binding</strong></a> can help you improve performance.
36+
</p>
37+
<p>
38+
If you are using <a href="https://docs.angularjs.org/api/ngResource"><strong>angular-resource</strong></a>, then you must resolve the promise and then set to your <code>$scope</code> in order to use the <code>one time binding</code>.
39+
</p>
40+
</div>
3341
</section>
3442
<section class="showcase">
3543
<tabset>
@@ -82,6 +90,42 @@ <h1><i class="fa fa-play"></i>&nbsp;The Angular way</h1>
8290
angular.module('datatablesSampleApp', ['ngResource', 'datatables']).controller('angularWayCtrl', function ($scope, $resource) {
8391
$scope.persons = $resource('data.json').query();
8492
});
93+
</div>
94+
</tab>
95+
<tab heading="HTML with One time binding">
96+
<div hljs>
97+
<div ng-controller="angularWayOneTimeBindingCtrl">
98+
<table datatable="ng" class="row-border hover">
99+
<thead>
100+
<tr>
101+
<th>ID</th>
102+
<th>FirstName</th>
103+
<th>LastName</th>
104+
</tr>
105+
</thead>
106+
<tbody>
107+
<tr ng-repeat="person in ::persons">
108+
<td>{{ person.id }}</td>
109+
<td>{{ person.firstName }}</td>
110+
<td>{{ person.lastName }}</td>
111+
</tr>
112+
</tbody>
113+
</table>
114+
</div>
115+
</div>
116+
</tab>
117+
<tab heading="JS with One time binding">
118+
<div hljs language="js">
119+
angular.module('datatablesSampleApp', ['ngResource', 'datatables'])
120+
.controller('angularWayOneTimeBindingCtrl', function($scope, $resource) {
121+
// This does not work if you want to bind once
122+
// $scope.persons = $resource('data.json').query();
123+
124+
// This works
125+
$resource('data.json').query().then(function(persons) {
126+
$scope.persons = persons;
127+
});
128+
});
85129
</div>
86130
</tab>
87131
<tab heading="Example data">

demo/basic/angularWay.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
'use strict';
2-
angular.module('datatablesSampleApp').controller('angularWayCtrl', function ($scope, $resource) {
3-
$scope.persons = $resource('data.json').query();
2+
angular.module('datatablesSampleApp').controller('angularWayCtrl', function($scope, $resource) {
3+
$resource('data.json').query().$promise.then(function(persons) {
4+
$scope.persons = persons;
5+
});
46
});

vendor/angular-resource/.bower.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
{
22
"name": "angular-resource",
3-
"version": "1.2.6",
3+
"version": "1.3.2",
44
"main": "./angular-resource.js",
5+
"ignore": [],
56
"dependencies": {
6-
"angular": "1.2.6"
7+
"angular": "1.3.2"
78
},
89
"homepage": "https://github.com/angular/bower-angular-resource",
9-
"_release": "1.2.6",
10+
"_release": "1.3.2",
1011
"_resolution": {
1112
"type": "version",
12-
"tag": "v1.2.6",
13-
"commit": "9a7ba02d8d139f5cce46beec6f9f68496f8f7937"
13+
"tag": "v1.3.2",
14+
"commit": "118de24ac662f8d5b2a573f93cf4f72f2d0a50f4"
1415
},
1516
"_source": "git://github.com/angular/bower-angular-resource.git",
16-
"_target": "1.2.6",
17+
"_target": "~1.3.2",
1718
"_originalSource": "angular-resource",
1819
"_direct": true
1920
}

vendor/angular-resource/README.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,35 @@
1-
# bower-angular-resource
1+
# packaged angular-resource
22

3-
This repo is for distribution on `bower`. The source for this module is in the
3+
This repo is for distribution on `npm` and `bower`. The source for this module is in the
44
[main AngularJS repo](https://github.com/angular/angular.js/tree/master/src/ngResource).
55
Please file issues and pull requests against that repo.
66

77
## Install
88

9-
Install with `bower`:
9+
You can install this package either with `npm` or with `bower`.
10+
11+
### npm
12+
13+
```shell
14+
npm install angular-resource
15+
```
16+
17+
Add a `<script>` to your `index.html`:
18+
19+
```html
20+
<script src="/node_modules/angular-resource/angular-resource.js"></script>
21+
```
22+
23+
Then add `ngResource` as a dependency for your app:
24+
25+
```javascript
26+
angular.module('myApp', ['ngResource']);
27+
```
28+
29+
Note that this package is not in CommonJS format, so doing `require('angular-resource')` will
30+
return `undefined`.
31+
32+
### bower
1033

1134
```shell
1235
bower install angular-resource
@@ -18,7 +41,7 @@ Add a `<script>` to your `index.html`:
1841
<script src="/bower_components/angular-resource/angular-resource.js"></script>
1942
```
2043

21-
And add `ngResource` as a dependency for your app:
44+
Then add `ngResource` as a dependency for your app:
2245

2346
```javascript
2447
angular.module('myApp', ['ngResource']);

0 commit comments

Comments
 (0)