Skip to content

Commit eddb8ce

Browse files
committedApr 23, 2017
WIP - first pass at using ES6 classes on front-end (no transpiling)
1 parent 66db9aa commit eddb8ce

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed
 

‎bs-config.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module.exports = {
22
files: [
33
'public/index.html',
44
'public/app.js',
5+
'public/template.js',
56
'public/stylesheets/styles.css'
67
],
78
proxy: {

‎public/javascripts/angular-app.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
(function() {
2-
angular.module('app', ['ngRoute'])
3-
.config(config);
1+
class AppConfig {
42

5-
config.$inject = ['$routeProvider', '$locationProvider'];
6-
7-
function config($routeProvider, $locationProvider) {
3+
constructor ($routeProvider, $locationProvider) {
84

95
// routing
106
$locationProvider.html5Mode(true);
@@ -21,11 +17,17 @@
2117
template: `
2218
<h1>MEAN Squad Library</h1>
2319
<p>Welcome to <em>MEAN Squad Library</em>, a library web application built with the MEAN Stack.
24-
<records-counts><records-counts>
20+
<records-counts></records-counts>
2521
`
2622
})
2723
}
28-
})();
24+
25+
}
26+
27+
angular.module('app', ['ngRoute'])
28+
.config(AppConfig);
29+
30+
2931

3032

3133

‎public/javascripts/components/records/records-counts.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ <h1>Library Records</h1>
33
<p>The library has the following record counts:</p>
44

55
<ul>
6-
<li><strong>Books:</strong> {{count}}</li>
6+
<li><strong>Books:</strong> {{$ctrl.count}}</li>
77
</ul>
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
(function() {
2-
3-
angular.module('app').directive('recordsCounts', Directive);
4-
5-
function Directive() {
6-
return {
7-
restrict: 'E',
8-
controller: Controller,
9-
templateUrl: '/records/records-counts.html',
10-
}
11-
}
12-
13-
Controller.$inject = ['$scope'];
14-
15-
function Controller($scope) {
16-
$scope.count = 11;
17-
}
18-
19-
})();
1+
class RecordsCountsController {
2+
$onInit() {
3+
this.count = 28;
4+
}
5+
}
6+
7+
const RecordsCountsComponent = {
8+
restrict: 'E',
9+
controller: RecordsCountsController,
10+
templateUrl: '/records/records-counts.html'
11+
};
12+
13+
angular.module('app').component('recordsCounts', RecordsCountsComponent);

0 commit comments

Comments
 (0)
Please sign in to comment.