Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%><% if(changeDetection !== 'Default') { %>, ChangeDetectionStrategy<% }%> } from '@angular/core';

@Component({
selector: '<%= selector %>',<% if(inlineTemplate) { %>
@Component({<% if(!skipSelector) {%>
selector: '<%= selector %>',<%}%><% if(inlineTemplate) { %>
template: `
<p>
<%= dasherize(name) %> works!
Expand Down
9 changes: 9 additions & 0 deletions packages/schematics/angular/component/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,15 @@ describe('Component Schematic', () => {
expect(content).toMatch(/selector: 'app-test'/);
});

it('should respect the skipSelector option', async () => {
const options = { ...defaultOptions, name: 'sub/test', skipSelector: true };
appTree = await schematicRunner.runSchematicAsync('component', options, appTree)
.toPromise();
const content = appTree.readContent('/projects/bar/src/app/sub/test/test.component.ts');
expect(content).not.toMatch(/selector: 'app-test'/);
console.log(content);
});

it('should respect the sourceRoot value', async () => {
const config = JSON.parse(appTree.readContent('/angular.json'));
config.projects.bar.sourceRoot = 'projects/bar/custom';
Expand Down
5 changes: 5 additions & 0 deletions packages/schematics/angular/component/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@
"format": "html-selector",
"description": "The HTML selector to use for this component."
},
"skipSelector": {
"type": "boolean",
"default": false,
"description": "Specifies if the component should have a selector or not."
},
"module": {
"type": "string",
"description": "The declaring NgModule.",
Expand Down