diff --git a/projects/cdk/schematics/ng-update/v4/steps/templates/migrate-labeled.ts b/projects/cdk/schematics/ng-update/v4/steps/templates/migrate-labeled.ts index 30c8d7314830..44b4b021bbdd 100644 --- a/projects/cdk/schematics/ng-update/v4/steps/templates/migrate-labeled.ts +++ b/projects/cdk/schematics/ng-update/v4/steps/templates/migrate-labeled.ts @@ -72,7 +72,8 @@ export function migrateLabeled({ ); recorder.remove( templateOffset + (sourceCodeLocation.endTag?.startOffset ?? 0), - `<${tagName}/>`.length, + (sourceCodeLocation.endTag?.endOffset ?? 0) - + (sourceCodeLocation.endTag?.startOffset ?? 0), ); recorder.insertRight( templateOffset + (sourceCodeLocation.endTag?.startOffset || 1), diff --git a/projects/cdk/schematics/ng-update/v4/tests/schematic-migrate-labeled.spec.ts b/projects/cdk/schematics/ng-update/v4/tests/schematic-migrate-labeled.spec.ts index 84b9bfd5e719..8c11842947e6 100644 --- a/projects/cdk/schematics/ng-update/v4/tests/schematic-migrate-labeled.spec.ts +++ b/projects/cdk/schematics/ng-update/v4/tests/schematic-migrate-labeled.spec.ts @@ -44,6 +44,14 @@ const TEMPLATE_BEFORE = ` Label + +{{ language.name }} `; const TEMPLATE_AFTER = `