选择器 "new-selector" 不匹配任何元素

The selector "new-selector" did not match any elements

我需要将 app.component.ts 中的选择器名称(选择器:'app-root')更改为其他名称。

让它成为选择器:'new-selector'。

显示,

错误:"The selector "新选择器“不匹配任何元素”

选择器名称更改后,哪些文件会受到影响?如何解决?

如果您更改 app.component.ts

的选择器名称

那么你需要在index.html

中更改它
from  <app-root> </app-root>
to    <new-selector> </new-selector>

必须进行的更改是:

HTML:

<app-root> to <new-selector>

Component.ts:

@Component {
  selector: 'new-selector'    //change here from app-root to new-selector 
 }

希望对您有所帮助!!,如果没有,请在 stackblitz 上分享一个工作示例