https://github.com/patrickjs/ng2for1
angular1 hacks for angular2 style coding
https://github.com/patrickjs/ng2for1
Last synced: 9 months ago
JSON representation
angular1 hacks for angular2 style coding
- Host: GitHub
- URL: https://github.com/patrickjs/ng2for1
- Owner: PatrickJS
- License: mit
- Created: 2015-02-22T20:14:03.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-03-02T20:16:56.000Z (almost 11 years ago)
- Last Synced: 2024-10-05T09:20:50.862Z (about 1 year ago)
- Language: JavaScript
- Size: 609 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ng2for1
angular1 hacks for angular2 style coding
## Example
```es6
import angular from 'exports?window.angular!angular';
function HelloWorld({ Component, Template }) {
Component({
selector: 'helloWorld',
bind: {
'yoAttr': '='
},
event: {
'click': 'clicking'
},
lifecycle: {
start: 'start',
before: 'before',
ready: 'ready',
destory: 'destory'
}
});
Template({
inline: `
Test tet {{ yolo }} {{ yoAttr }} {{ kool }}
`
});
class World {
constructor($scope) {
console.log('swag', $scope);
this.yolo = 'yolo';
$scope.kool = 'kool';
}
yolo() {
}
clicking($event) {
console.log('yolo', this.yolo, $event);
if (this.yolo === 'lol') {
this.yolo = 'yolo';
} else {
this.yolo = 'lol';
}
}
start() {
console.log('Start', arguments);
}
before() {
console.log('Before', arguments);
}
ready() {
console.log('Ready', arguments);
}
destory() {
console.log('Destory', arguments);
}
}
return World;
};
export default angular.module('component', []).component('helloWorld', HelloWorld);
```
## Todo
* remove state out of annotation service
* create a better annotation service
* fix lifecyle