Skip to content

Commit

Permalink
refactor core part with es6 syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
leftstick committed Feb 2, 2016
1 parent 34788b2 commit 374e515
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 25 deletions.
Expand Up @@ -24,7 +24,7 @@ class HomeController {
_init_() {
this.state = {};
this.HomeService.getStates()
.success((data) => this.states = data);
.success(data => this.states = data);
}

toast() {
Expand All @@ -49,9 +49,7 @@ class HomeController {
}

_destroy_() {
this.$scope.$on('$destroy', function() {
console.log('asdfsafa');
});
this.$scope.$on('$destroy', function() {});
}
}

Expand Down
Expand Up @@ -21,8 +21,8 @@ class ListController {
_init_() {
this.ListService
.getDemoList()
.success((data) => this.demolist = data)
.error((err) => console.log(err));
.success(data => this.demolist = data)
.error(err => console.log(err));
}

_destroy_() {
Expand Down
25 changes: 10 additions & 15 deletions generators/app/templates/js/main.js
Expand Up @@ -18,20 +18,18 @@ class App {

constructor() {
this.appName = '<%= answers.name %>';
this.features = [];
Features.forEach(function(Feature) {
this.features.push(new Feature());
}, this);
this.push(new Feature());
}, this.features = []);
}

findDependencies() {
this.depends = Extensions.slice(0);
var featureNames = this.features.filter(function(feature) {
return feature.export;
})
.map(function(feature) {
return feature.export;
});

var featureNames = this.features
.filter(feature => feature.export)
.map(feature => feature.export);

this.depends.push(...featureNames);
}

Expand All @@ -40,15 +38,12 @@ class App {
(new Initializer(this.features)).execute();
}, this);

this.features.forEach(function(feature) {
feature.beforeStart();
});
this.features.forEach(feature => feature.beforeStart());
}

createApp() {
this.features.forEach(function(feature) {
feature.execute();
});
this.features.forEach(feature => feature.execute());

this.app = angular.module(this.appName, this.depends);
}

Expand Down
4 changes: 2 additions & 2 deletions generators/app/templates/package.json_vm
Expand Up @@ -26,7 +26,7 @@
"angular-sanitize": "^1.4.9",
"angular-aria": "^1.4.9",
"angular-messages": "^1.4.9",
"angular-material": "^1.0.2",
"angular-material": "^1.0.4",
"splash-screen": "^2.2.2"
},
"devDependencies": {
Expand All @@ -41,7 +41,7 @@
"gulp": "^3.9.0",
"gulp-replace": "^0.5.4",
"gulp-util": "^3.0.7",
"less": "^2.5.3",
"less": "^2.6.0",
"less-loader": "^2.2.2",
"postcss-loader": "^0.8.0",
"raw-loader": "^0.5.1",
Expand Down
4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "generator-es6-angular",
"version": "4.0.0",
"version": "4.0.1",
"description": "generator-es6-angular",
"repository": {
"type": "git",
Expand All @@ -22,7 +22,7 @@
"license": "MIT",
"dependencies": {
"date-util": "^1.2.1",
"lodash": "^4.0.1",
"lodash": "^4.1.0",
"yeoman-generator": "^0.22.5"
}
}

0 comments on commit 374e515

Please sign in to comment.