Angular 索引页如何知道要加载哪个应用程序标记
对于index.html页面,我有一个标记,在我的app.component.ts中,选择器是“app”。在my component.ts中,选择器也是“app”。angular 7如何知道要选择哪个html页面以及要选择哪个应用程序,因为它们的名称相同Angular 索引页如何知道要加载哪个应用程序标记,angular,Angular,对于index.html页面,我有一个标记,在我的app.component.ts中,选择器是“app”。在my component.ts中,选择器也是“app”。angular 7如何知道要选择哪个html页面以及要选择哪个应用程序,因为它们的名称相同 app.component.ts: import { Component } from '@angular/core'; @Component({ selector: 'app', templateUrl: './app.compo
app.component.ts:
import { Component } from '@angular/core';
@Component({
selector: 'app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'example';
}
component.ts:
import { ApplicationRef, Component } from "@angular/core";
@Component({
selector: "app",
templateUrl: "template.html",
styles: ["/deep/ div { border: 2px black solid; font-style:italic }"]
})
export class ProductComponent {
}
我不知道。如果使用同一选择器声明两个不同的组件,并尝试在同一模块中使用它们,则会出现错误。您可能不会立即注意到错误,因为Angular需要在同一模块中使用两个冲突的组件才能开始抛出错误。不允许有多个同名选择器,因此Angular:DIn在app-component.ts中没有什么可决定的。如果我将选择器从selector更改为:“app”,对于选择器:“app-1”,我收到以下错误:,选择器“app-1”与DefaultDomRender2.pushIt处的任何元素都不匹配。当我加载index.html页面时,它似乎指向app-component.ts。那套在哪里?