Skip to content

Commit b852c3f

Browse files
BroccoJonathan Jayet
authored and
Jonathan Jayet
committed
chore: simplify inline style & template for mobile apps (angular#2476)
1 parent d3d9060 commit b852c3f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

packages/angular-cli/blueprints/ng2/files/__path__/app/app.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { Component } from '@angular/core';<% if (isMobile) { %>
22
import { APP_SHELL_DIRECTIVES } from '@angular/app-shell';<% } %>
33

44
@Component({
5-
selector: '<%= prefix %>-root',<% if (isMobile || inlineTemplate) { %>
5+
selector: '<%= prefix %>-root',<% if (inlineTemplate) { %>
66
template: `
77
<h1>
88
{{title}}
99
</h1>
1010
`,<% } else { %>
11-
templateUrl: './app.component.html',<% } %><% if (isMobile || inlineStyle) { %>
11+
templateUrl: './app.component.html',<% } %><% if (inlineStyle) { %>
1212
styles: []<% } else { %>
1313
styleUrls: ['./app.component.<%= styleExt %>']<% } %>
1414
})

packages/angular-cli/blueprints/ng2/index.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ module.exports = {
3232
.replace(/-(.)/g, (_, l) => ' ' + l.toUpperCase())
3333
.replace(/^./, (l) => l.toUpperCase());
3434

35+
// For mobile projects, force inline styles and templates.
36+
if (options.mobile) {
37+
options.inlineStyle = true;
38+
options.inlineTemplate = true;
39+
}
40+
3541
return {
3642
htmlComponentName: stringUtils.dasherize(options.entity.name),
3743
jsComponentName: stringUtils.classify(options.entity.name),
@@ -50,10 +56,7 @@ module.exports = {
5056

5157
files: function() {
5258
var fileList = getFiles.call(this);
53-
if (this.options && this.options.mobile) {
54-
fileList = fileList.filter(p => p.indexOf('app.component.html') < 0);
55-
fileList = fileList.filter(p => p.indexOf('app.component.__styleext__') < 0);
56-
}
59+
5760
if (this.options && !this.options.routing) {
5861
fileList = fileList.filter(p => p.indexOf('app-routing.module.ts') < 0);
5962
}

0 commit comments

Comments
 (0)