Skip to content

Commit 312384d

Browse files
committed
Merge pull request #1692 from angular-fullstack/angular-1.5
Angular 1.5
2 parents 8b04ec4 + 6899dd6 commit 312384d

File tree

7 files changed

+54
-43
lines changed

7 files changed

+54
-43
lines changed

Diff for: app/templates/_bower.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
"name": "<%= lodash.slugify(lodash.humanize(appname)) %>",
33
"version": "0.0.0",
44
"dependencies": {
5-
"angular": "~1.4.0",
5+
"angular": "~1.5.0",
66
"json3": "~3.3.1",
77
"es5-shim": "~3.0.1",<% if(filters.bootstrap) { if (filters.sass) { %>
88
"bootstrap-sass-official": "~3.1.1",<% } %>
99
"bootstrap": "~3.1.1",<% if(filters.oauth) { %>
1010
"bootstrap-social": "~4.9.1",<% }} %>
11-
"angular-resource": "~1.4.0",
12-
"angular-cookies": "~1.4.0",
13-
"angular-sanitize": "~1.4.0",<% if (filters.ngroute) { %>
14-
"angular-route": "~1.4.0",<% } if (filters.uibootstrap) { %>
11+
"angular-resource": "~1.5.0",
12+
"angular-cookies": "~1.5.0",
13+
"angular-sanitize": "~1.5.0",<% if (filters.ngroute) { %>
14+
"angular-route": "~1.5.0",<% } if (filters.uibootstrap) { %>
1515
"angular-bootstrap": "~1.1.2",<% } %>
1616
"font-awesome": ">=4.1.0",
1717
"lodash": "~2.4.1"<% if(filters.socketio) { %>,
@@ -20,6 +20,6 @@
2020
"angular-validation-match": "~1.5.2"<% } %>
2121
},
2222
"devDependencies": {
23-
"angular-mocks": "~1.4.0"
23+
"angular-mocks": "~1.5.0"
2424
}
2525
}

Diff for: app/templates/_package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
"karma-chrome-launcher": "~0.2.0",
147147
"karma-requirejs": "~0.2.2",
148148
"karma-jade-preprocessor": "0.0.11",
149-
"karma-phantomjs-launcher": "~0.2.0",<% if (filters.jade) { %>
149+
"karma-phantomjs-launcher": "~1.0.0",<% if (filters.jade) { %>
150150
"karma-ng-jade2js-preprocessor": "^0.2.0",<% } else { %>
151151
"karma-ng-html2js-preprocessor": "~0.2.0",<% } %>
152152
"karma-spec-reporter": "~0.0.20",
@@ -159,7 +159,7 @@
159159
"jasmine-spec-reporter": "^2.4.0",<% } if(filters.babel) { %>
160160
"karma-babel-preprocessor": "^5.2.1",<% } %>
161161
"requirejs": "~2.1.11",
162-
"phantomjs": "^1.9.18",
162+
"phantomjs-prebuilt": "^2.1.4",
163163
"proxyquire": "^1.0.1",
164164
"supertest": "^1.1.0"
165165
},

Diff for: app/templates/client/app/main/main(html).html

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ <h1>'Allo, 'Allo!</h1>
1010
<div class="row">
1111
<div class="col-lg-12">
1212
<h1 class="page-header">Features:</h1>
13-
<ul class="nav nav-tabs nav-stacked col-md-4 col-lg-4 col-sm-6" ng-repeat="thing in main.awesomeThings">
14-
<li><a href="#" uib-tooltip="{{thing.info}}">{{thing.name}}<% if (filters.socketio) { %><button type="button" class="close" ng-click="main.deleteThing(thing)">&times;</button><% } %></a></li>
13+
<ul class="nav nav-tabs nav-stacked col-md-4 col-lg-4 col-sm-6" ng-repeat="thing in $ctrl.awesomeThings">
14+
<li><a href="#" uib-tooltip="{{thing.info}}">{{thing.name}}<% if (filters.socketio) { %><button type="button" class="close" ng-click="$ctrl.deleteThing(thing)">&times;</button><% } %></a></li>
1515
</ul>
1616
</div>
1717
</div><% if (filters.socketio) { %>
1818

1919
<form class="thing-form">
2020
<label>Syncs in realtime across clients</label>
2121
<p class="input-group">
22-
<input type="text" class="form-control" placeholder="Add a new thing here." ng-model="main.newThing">
22+
<input type="text" class="form-control" placeholder="Add a new thing here." ng-model="$ctrl.newThing">
2323
<span class="input-group-btn">
24-
<button type="submit" class="btn btn-primary" ng-click="main.addThing()">Add New</button>
24+
<button type="submit" class="btn btn-primary" ng-click="$ctrl.addThing()">Add New</button>
2525
</span>
2626
</p>
2727
</form><% } %>

Diff for: app/templates/client/app/main/main(jade).jade

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ header#banner.hero-unit
88
.row
99
.col-lg-12
1010
h1.page-header Features:
11-
ul.nav.nav-tabs.nav-stacked.col-md-4.col-lg-4.col-sm-6(ng-repeat='thing in main.awesomeThings')
11+
ul.nav.nav-tabs.nav-stacked.col-md-4.col-lg-4.col-sm-6(ng-repeat='thing in $ctrl.awesomeThings')
1212
li
1313
a(href='#', uib-tooltip='{{thing.info}}')
1414
| {{thing.name}}<% if (filters.socketio) { %>
15-
button.close(type='button', ng-click='main.deleteThing(thing)') &times;<% } %><% if (filters.socketio) { %>
15+
button.close(type='button', ng-click='$ctrl.deleteThing(thing)') &times;<% } %><% if (filters.socketio) { %>
1616

1717
form.thing-form
1818
label Syncs in realtime across clients
1919
p.input-group
20-
input.form-control(type='text', placeholder='Add a new thing here.', ng-model='main.newThing')
20+
input.form-control(type='text', placeholder='Add a new thing here.', ng-model='$ctrl.newThing')
2121
span.input-group-btn
22-
button.btn.btn-primary(type='submit', ng-click='main.addThing()') Add New<% } %>
22+
button.btn.btn-primary(type='submit', ng-click='$ctrl.addThing()') Add New<% } %>

Diff for: app/templates/client/app/main/main.controller.js

+14-8
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@
55
class MainController {
66

77
constructor($http<% if (filters.socketio) { %>, $scope, socket<% } %>) {
8-
this.$http = $http;
9-
this.awesomeThings = [];
10-
11-
$http.get('/api/things').then(response => {
12-
this.awesomeThings = response.data;<% if (filters.socketio) { %>
13-
socket.syncUpdates('thing', this.awesomeThings);<% } %>
14-
});<% if (filters.socketio) { %>
8+
this.$http = $http;<% if (filters.socketio) { %>
9+
this.socket = socket;<% } %>
10+
this.awesomeThings = [];<% if (filters.socketio) { %>
1511

1612
$scope.$on('$destroy', function() {
1713
socket.unsyncUpdates('thing');
1814
});<% } %>
15+
}
16+
17+
$onInit() {
18+
this.$http.get('/api/things').then(response => {
19+
this.awesomeThings = response.data;<% if (filters.socketio) { %>
20+
this.socket.syncUpdates('thing', this.awesomeThings);<% } %>
21+
});
1922
}<% if (filters.models) { %>
2023

2124
addThing() {
@@ -31,6 +34,9 @@ class MainController {
3134
}
3235

3336
angular.module('<%= scriptAppName %>')
34-
.controller('MainController', MainController);
37+
.component('main', {
38+
templateUrl: 'app/main/main.html',
39+
controller: MainController
40+
});
3541

3642
})();
+22-13
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,42 @@
11
'use strict';
22

3-
describe('Controller: MainController', function() {
3+
describe('Component: mainComponent', function() {
44

55
// load the controller's module
66
beforeEach(module('<%= scriptAppName %>'));<% if (filters.uirouter) {%>
77
beforeEach(module('stateMock'));<% } %><% if (filters.socketio) {%>
88
beforeEach(module('socketMock'));<% } %>
99

1010
var scope;
11-
var MainController;<% if (filters.uirouter) {%>
11+
var mainComponent;<% if (filters.uirouter) {%>
1212
var state;<% } %>
1313
var $httpBackend;
1414

1515
// Initialize the controller and a mock scope
16-
beforeEach(inject(function(_$httpBackend_, $controller, $rootScope<% if (filters.uirouter) {%>, $state<% } %>) {
17-
$httpBackend = _$httpBackend_;
18-
$httpBackend.expectGET('/api/things')
19-
.respond(['HTML5 Boilerplate', 'AngularJS', 'Karma', 'Express']);
16+
beforeEach(inject(function(
17+
_$httpBackend_,
18+
$http,
19+
$componentController,
20+
$rootScope<% if (filters.uirouter) {%>,
21+
$state<% } %><% if (filters.socketio) {%>,
22+
socket<% } %>) {
23+
$httpBackend = _$httpBackend_;
24+
$httpBackend.expectGET('/api/things')
25+
.respond(['HTML5 Boilerplate', 'AngularJS', 'Karma', 'Express']);
2026

21-
scope = $rootScope.$new();<% if (filters.uirouter) {%>
22-
state = $state;<% } %>
23-
MainController = $controller('MainController', {
24-
$scope: scope
25-
});
27+
scope = $rootScope.$new();<% if (filters.uirouter) {%>
28+
state = $state;<% } %>
29+
mainComponent = $componentController('main', {
30+
$http: $http,
31+
$scope: scope<% if (filters.socketio) {%>,
32+
socket: socket<% } %>
33+
});
2634
}));
2735

2836
it('should attach a list of things to the controller', function() {
37+
mainComponent.$onInit();
2938
$httpBackend.flush();<% if (filters.jasmine) { %>
30-
expect(MainController.awesomeThings.length).toBe(4);<% } if (filters.mocha) { %>
31-
<%= expect() %>MainController.awesomeThings.length<%= to() %>.equal(4);<% } %>
39+
expect(mainComponent.awesomeThings.length).toBe(4);<% } if (filters.mocha) { %>
40+
<%= expect() %>mainComponent.awesomeThings.length<%= to() %>.equal(4);<% } %>
3241
});
3342
});

Diff for: app/templates/client/app/main/main.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ angular.module('<%= scriptAppName %>')
44
<% if (filters.ngroute) { %>.config(function($routeProvider) {
55
$routeProvider
66
.when('/', {
7-
templateUrl: 'app/main/main.html',
8-
controller: 'MainController',
9-
controllerAs: 'main'
7+
template: '<main></main>'
108
});
119
});<% } %><% if (filters.uirouter) { %>.config(function($stateProvider) {
1210
$stateProvider
1311
.state('main', {
1412
url: '/',
15-
templateUrl: 'app/main/main.html',
16-
controller: 'MainController',
17-
controllerAs: 'main'
13+
template: '<main></main>'
1814
});
1915
});<% } %>

0 commit comments

Comments
 (0)