选择器“new-selector”与任何元素都不匹配

问题描述 投票:1回答:2

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

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

表明,

错误:“选择器”新选择器“与任何元素都不匹配”

当选择器名称发生更改时,所有文件都会受到影响?怎么解决?

angular typescript angularjs-directive
2个回答
1
投票

如果更改app.component.ts的选择器名称

然后你需要在index.html中更改它

from  <app-root> </app-root>
to    <new-selector> </new-selector>

0
投票

必须进行的更改包括:

HTML:

<app-root> to <new-selector>

Component.ts:

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

希望有所帮助!!如果没有,请分享一个关于stackblitz的工作示例

© www.soinside.com 2019 - 2024. All rights reserved.