Skip to content

Commit a358c1a

Browse files
cironuneseddiemonge
authored andcommitted
fix(build): deselecting ngRoute does remove route stuff
ngRoute should only add route info when it is selected Closes #486 and #451 BREAKING CHANGE: Deselecting ngRoute adds controller and ng-include to index.html
1 parent d20f5bd commit a358c1a

File tree

7 files changed

+17
-7
lines changed

7 files changed

+17
-7
lines changed

Diff for: app/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ Generator.prototype.askForModules = function askForModules() {
175175
}
176176
if (this.routeModule) {
177177
angMods.push("'ngRoute'");
178+
this.env.options.ngRoute = true;
178179
}
179180

180181
if (angMods.length) {
@@ -186,6 +187,7 @@ Generator.prototype.askForModules = function askForModules() {
186187
};
187188

188189
Generator.prototype.readIndex = function readIndex() {
190+
this.ngRoute = this.env.options.ngRoute;
189191
this.indexFile = this.engine(this.read('../../templates/common/index.html'), this);
190192
};
191193

@@ -277,6 +279,7 @@ Generator.prototype.appJs = function appJs() {
277279
};
278280

279281
Generator.prototype.createIndexHtml = function createIndexHtml() {
282+
this.indexFile = this.indexFile.replace(/'/g, "'");
280283
this.write(path.join(this.appPath, 'index.html'), this.indexFile);
281284
};
282285

Diff for: main/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ util.inherits(Generator, ScriptBase);
1313

1414
Generator.prototype.createAppFile = function createAppFile() {
1515
this.angularModules = this.env.options.angularDeps;
16+
this.ngRoute = this.env.options.ngRoute;
1617
this.appTemplate('app', 'scripts/app');
1718
};

Diff for: templates/coffeescript-min/app.coffee

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
angular.module('<%= scriptAppName %>', [<%= angularModules %>])
3+
angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
44
.config ['$routeProvider', ($routeProvider) ->
55
$routeProvider
66
.when '/',
@@ -9,3 +9,4 @@ angular.module('<%= scriptAppName %>', [<%= angularModules %>])
99
.otherwise
1010
redirectTo: '/'
1111
]
12+
<% } %>

Diff for: templates/coffeescript/app.coffee

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
'use strict'
22

3-
angular.module('<%= scriptAppName %>', [<%= angularModules %>])
3+
angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
44
.config ($routeProvider) ->
55
$routeProvider
66
.when '/',
77
templateUrl: 'views/main.html'
88
controller: 'MainCtrl'
99
.otherwise
1010
redirectTo: '/'
11+
<% } %>

Diff for: templates/common/index.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
<![endif]-->
2323

2424
<!-- Add your site or application content here -->
25-
<div class="container" ng-view></div>
25+
<% if (ngRoute) {
26+
%><div class="container" ng-view></div><%
27+
} else {
28+
%><div class="container" ng-include="'views/main.html'" ng-controller="MainCtrl"></div><%
29+
} %>
2630

2731
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID -->
2832
<script>

Diff for: templates/javascript-min/app.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
angular.module('<%= scriptAppName %>', [<%= angularModules %>])
3+
angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
44
.config(['$routeProvider', function ($routeProvider) {
55
$routeProvider
66
.when('/', {
@@ -10,4 +10,4 @@ angular.module('<%= scriptAppName %>', [<%= angularModules %>])
1010
.otherwise({
1111
redirectTo: '/'
1212
});
13-
}]);
13+
}])<% } %>;

Diff for: templates/javascript/app.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
angular.module('<%= scriptAppName %>', [<%= angularModules %>])
3+
angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
44
.config(function ($routeProvider) {
55
$routeProvider
66
.when('/', {
@@ -10,4 +10,4 @@ angular.module('<%= scriptAppName %>', [<%= angularModules %>])
1010
.otherwise({
1111
redirectTo: '/'
1212
});
13-
});
13+
})<% } %>;

0 commit comments

Comments
 (0)