https://github.com/chrisyip/ng-partialize
https://github.com/chrisyip/ng-partialize
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/chrisyip/ng-partialize
- Owner: chrisyip
- License: mit
- Created: 2015-08-17T06:49:32.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-08-26T07:36:23.000Z (almost 11 years ago)
- Last Synced: 2025-02-17T06:41:31.319Z (over 1 year ago)
- Language: JavaScript
- Size: 140 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ng-partialize
Example:
Common logic (`common.js`) :
```js
angular.module('myApp', [])
.controller('demoCtrl', function ($scope) {
$scope.query(function (items) {
$scope.items = items
$scope.pagination = {
count: items.length,
total: getTotal()
}
})
$scope.onClick = function (item) {
$scope.showDetail(item)
}
})
```
Web app A:
```html
<script src="ng-partialize.js"
<script src="list.js"
```
`list.js`:
```js
angular.module('myApp')
.beforeController('demoCtrl', function ($scope, List) {
$scope.query = function (cb) {
return List.query(cb)
}
$scope.showDetail = function () { /* do something */ }
})
.afterController('demoCtrl', function ($scope) {
$scope.$watch('items', function (val) {
if (val) {
$scope.list = val.map(function (item) { /* do something */ })
}
})
})
```
Web app B:
```html
<script src="ng-partialize.js"
<script src="article.js"
```
`article.js`:
```js
angular.module('myApp')
.beforeController('demoCtrl', function ($scope, Article) {
$scope.query = function (cb) {
return Article.query(cb)
}
$scope.showDetail = function () { /* do something */ }
})
.afterController('demoCtrl', function ($scope) {
$scope.$watch('items', function (val) {
if (val) {
$scope.articles = val.map(function (item) { /* do something */ })
}
})
})
```
# Author
[Chris Yip](https://github.com/chrisyip)