mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(schematics): add app prefix to components (#11738)
This commit is contained in:
@@ -82,17 +82,17 @@ function addDeclarationToNgModule(options: any): Rule {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function buildSelector(options: any) {
|
||||
function buildSelector(options: any, projectPrefix: string) {
|
||||
let selector = strings.dasherize(options.name);
|
||||
if (options.prefix) {
|
||||
selector = `${options.prefix}-${selector}`;
|
||||
} else if (options.prefix === undefined && projectPrefix) {
|
||||
selector = `${projectPrefix}-${selector}`;
|
||||
}
|
||||
|
||||
return selector;
|
||||
}
|
||||
|
||||
|
||||
export function buildComponent(options: any): Rule {
|
||||
return (host: Tree, context: SchematicContext) => {
|
||||
const workspace = getWorkspace(host);
|
||||
@@ -105,7 +105,7 @@ export function buildComponent(options: any): Rule {
|
||||
options.path = `/${project.root}/src/app`;
|
||||
}
|
||||
|
||||
options.selector = options.selector || buildSelector(options);
|
||||
options.selector = options.selector || buildSelector(options, project.prefix);
|
||||
options.module = findModuleFromOptions(host, options);
|
||||
|
||||
const parsedPath = parseName(options.path, options.name);
|
||||
|
||||
@@ -49,6 +49,9 @@ export interface Workspace {
|
||||
export interface Project {
|
||||
name: string;
|
||||
|
||||
/** Application prefix. */
|
||||
prefix: string;
|
||||
|
||||
/** Project type. */
|
||||
projectType: 'application' | 'library';
|
||||
/** Root of the project sourcefiles. */
|
||||
|
||||
Reference in New Issue
Block a user