Skip to content

Angular 1.5 #1669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions app/templates/_bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
"name": "<%= lodash.slugify(lodash.humanize(appname)) %>",
"version": "0.0.0",
"dependencies": {
"angular": "~1.4.0",
"angular": "~1.5.0",
"json3": "~3.3.1",
"es5-shim": "~3.0.1",<% if(filters.bootstrap) { if (filters.sass) { %>
"bootstrap-sass-official": "~3.1.1",<% } %>
"bootstrap": "~3.1.1",<% if(filters.oauth) { %>
"bootstrap-social": "~4.9.1",<% }} %>
"angular-resource": "~1.4.0",
"angular-cookies": "~1.4.0",
"angular-sanitize": "~1.4.0",<% if (filters.ngroute) { %>
"angular-route": "~1.4.0",<% } if (filters.uibootstrap) { %>
"angular-resource": "~1.5.0",
"angular-cookies": "~1.5.0",
"angular-sanitize": "~1.5.0",<% if (filters.ngroute) { %>
"angular-route": "~1.5.0",<% } if (filters.uibootstrap) { %>
"angular-bootstrap": "~0.13.0",<% } %>
"font-awesome": ">=4.1.0",
"lodash": "~2.4.1"<% if(filters.socketio) { %>,
Expand All @@ -20,6 +20,6 @@
"angular-validation-match": "~1.5.2"<% } %>
},
"devDependencies": {
"angular-mocks": "~1.4.0"
"angular-mocks": "~1.5.0"
}
}
4 changes: 2 additions & 2 deletions app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"karma-chrome-launcher": "~0.2.0",
"karma-requirejs": "~0.2.2",
"karma-jade-preprocessor": "0.0.11",
"karma-phantomjs-launcher": "~0.2.0",<% if (filters.jade) { %>
"karma-phantomjs-launcher": "~1.0.0",<% if (filters.jade) { %>
"karma-ng-jade2js-preprocessor": "^0.2.0",<% } else { %>
"karma-ng-html2js-preprocessor": "~0.2.0",<% } %>
"karma-spec-reporter": "~0.0.20",
Expand All @@ -159,7 +159,7 @@
"jasmine-spec-reporter": "^2.4.0",<% } if(filters.babel) { %>
"karma-babel-preprocessor": "^5.2.1",<% } %>
"requirejs": "~2.1.11",
"phantomjs": "^1.9.18",
"phantomjs-prebuilt": "^2.1.4",
"proxyquire": "^1.0.1",
"supertest": "^1.1.0"
},
Expand Down
8 changes: 4 additions & 4 deletions app/templates/client/app/main/main(html).html
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ <h1>'Allo, 'Allo!</h1>
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Features:</h1>
<ul class="nav nav-tabs nav-stacked col-md-4 col-lg-4 col-sm-6" ng-repeat="thing in main.awesomeThings">
<li><a href="#" tooltip="{{thing.info}}">{{thing.name}}<% if (filters.socketio) { %><button type="button" class="close" ng-click="main.deleteThing(thing)">&times;</button><% } %></a></li>
<ul class="nav nav-tabs nav-stacked col-md-4 col-lg-4 col-sm-6" ng-repeat="thing in $ctrl.awesomeThings">
<li><a href="#" tooltip="{{thing.info}}">{{thing.name}}<% if (filters.socketio) { %><button type="button" class="close" ng-click="$ctrl.deleteThing(thing)">&times;</button><% } %></a></li>
</ul>
</div>
</div><% if (filters.socketio) { %>

<form class="thing-form">
<label>Syncs in realtime across clients</label>
<p class="input-group">
<input type="text" class="form-control" placeholder="Add a new thing here." ng-model="main.newThing">
<input type="text" class="form-control" placeholder="Add a new thing here." ng-model="$ctrl.newThing">
<span class="input-group-btn">
<button type="submit" class="btn btn-primary" ng-click="main.addThing()">Add New</button>
<button type="submit" class="btn btn-primary" ng-click="$ctrl.addThing()">Add New</button>
</span>
</p>
</form><% } %>
Expand Down
22 changes: 14 additions & 8 deletions app/templates/client/app/main/main.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
class MainController {

constructor($http<% if (filters.socketio) { %>, $scope, socket<% } %>) {
this.$http = $http;
this.awesomeThings = [];

$http.get('/api/things').then(response => {
this.awesomeThings = response.data;<% if (filters.socketio) { %>
socket.syncUpdates('thing', this.awesomeThings);<% } %>
});<% if (filters.socketio) { %>
this.$http = $http;<% if (filters.socketio) { %>
this.socket = socket;<% } %>
this.awesomeThings = [];<% if (filters.socketio) { %>

$scope.$on('$destroy', function() {
socket.unsyncUpdates('thing');
});<% } %>
}

$onInit() {
this.$http.get('/api/things').then(response => {
this.awesomeThings = response.data;<% if (filters.socketio) { %>
this.socket.syncUpdates('thing', this.awesomeThings);<% } %>
});
}<% if (filters.models) { %>

addThing() {
Expand All @@ -31,6 +34,9 @@ class MainController {
}

angular.module('<%= scriptAppName %>')
.controller('MainController', MainController);
.component('main', {
templateUrl: 'app/main/main.html',
controller: MainController
});

})();
17 changes: 10 additions & 7 deletions app/templates/client/app/main/main.controller.spec.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
'use strict';

describe('Controller: MainController', function() {
describe('Component: mainComponent', function() {

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

var scope;
var MainController;<% if (filters.uirouter) {%>
var mainComponent;<% if (filters.uirouter) {%>
var state;<% } %>
var $httpBackend;

// Initialize the controller and a mock scope
beforeEach(inject(function(_$httpBackend_, $controller, $rootScope<% if (filters.uirouter) {%>, $state<% } %>) {
beforeEach(inject(function(_$httpBackend_, $http, $componentController, $rootScope<% if (filters.uirouter) {%>, $state<% } %><% if (filters.socketio) {%>, socket<% } %>) {
$httpBackend = _$httpBackend_;
$httpBackend.expectGET('/api/things')
.respond(['HTML5 Boilerplate', 'AngularJS', 'Karma', 'Express']);

scope = $rootScope.$new();<% if (filters.uirouter) {%>
state = $state;<% } %>
MainController = $controller('MainController', {
$scope: scope
mainComponent = $componentController('main', {
$http: $http,
$scope: scope<% if (filters.socketio) {%>,
socket: socket<% } %>
});
}));

it('should attach a list of things to the controller', function() {
mainComponent.$onInit();
$httpBackend.flush();<% if (filters.jasmine) { %>
expect(MainController.awesomeThings.length).toBe(4);<% } if (filters.mocha) { %>
<%= expect() %>MainController.awesomeThings.length<%= to() %>.equal(4);<% } %>
expect(mainComponent.awesomeThings.length).toBe(4);<% } if (filters.mocha) { %>
<%= expect() %>mainComponent.awesomeThings.length<%= to() %>.equal(4);<% } %>
});
});
8 changes: 2 additions & 6 deletions app/templates/client/app/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ angular.module('<%= scriptAppName %>')
<% if (filters.ngroute) { %>.config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'app/main/main.html',
controller: 'MainController',
controllerAs: 'main'
template: '<main></main>'
});
});<% } %><% if (filters.uirouter) { %>.config(function($stateProvider) {
$stateProvider
.state('main', {
url: '/',
templateUrl: 'app/main/main.html',
controller: 'MainController',
controllerAs: 'main'
template: '<main></main>'
});
});<% } %>