Skip to content

Commit

Permalink
fix(build): deselecting ngRoute does remove route stuff
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cironunes authored and eddiemonge committed Dec 6, 2013
1 parent d20f5bd commit a358c1a
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 7 deletions.
3 changes: 3 additions & 0 deletions app/index.js
Expand Up @@ -175,6 +175,7 @@ Generator.prototype.askForModules = function askForModules() {
}
if (this.routeModule) {
angMods.push("'ngRoute'");
this.env.options.ngRoute = true;
}

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

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

Expand Down Expand Up @@ -277,6 +279,7 @@ Generator.prototype.appJs = function appJs() {
};

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

Expand Down
1 change: 1 addition & 0 deletions main/index.js
Expand Up @@ -13,5 +13,6 @@ util.inherits(Generator, ScriptBase);

Generator.prototype.createAppFile = function createAppFile() {
this.angularModules = this.env.options.angularDeps;
this.ngRoute = this.env.options.ngRoute;
this.appTemplate('app', 'scripts/app');
};
3 changes: 2 additions & 1 deletion templates/coffeescript-min/app.coffee
@@ -1,6 +1,6 @@
'use strict'

angular.module('<%= scriptAppName %>', [<%= angularModules %>])
angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
.config ['$routeProvider', ($routeProvider) ->
$routeProvider
.when '/',
Expand All @@ -9,3 +9,4 @@ angular.module('<%= scriptAppName %>', [<%= angularModules %>])
.otherwise
redirectTo: '/'
]
<% } %>
3 changes: 2 additions & 1 deletion templates/coffeescript/app.coffee
@@ -1,10 +1,11 @@
'use strict'

angular.module('<%= scriptAppName %>', [<%= angularModules %>])
angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
.config ($routeProvider) ->
$routeProvider
.when '/',
templateUrl: 'views/main.html'
controller: 'MainCtrl'
.otherwise
redirectTo: '/'
<% } %>
6 changes: 5 additions & 1 deletion templates/common/index.html
Expand Up @@ -22,7 +22,11 @@
<![endif]-->

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

<!-- Google Analytics: change UA-XXXXX-X to be your site's ID -->
<script>
Expand Down
4 changes: 2 additions & 2 deletions templates/javascript-min/app.js
@@ -1,6 +1,6 @@
'use strict';

angular.module('<%= scriptAppName %>', [<%= angularModules %>])
angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/', {
Expand All @@ -10,4 +10,4 @@ angular.module('<%= scriptAppName %>', [<%= angularModules %>])
.otherwise({
redirectTo: '/'
});
}]);
}])<% } %>;
4 changes: 2 additions & 2 deletions templates/javascript/app.js
@@ -1,6 +1,6 @@
'use strict';

angular.module('<%= scriptAppName %>', [<%= angularModules %>])
angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
.config(function ($routeProvider) {
$routeProvider
.when('/', {
Expand All @@ -10,4 +10,4 @@ angular.module('<%= scriptAppName %>', [<%= angularModules %>])
.otherwise({
redirectTo: '/'
});
});
})<% } %>;

0 comments on commit a358c1a

Please sign in to comment.