Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 索引页如何知道要加载哪个应用程序标记_Angular - Fatal编程技术网

Angular 索引页如何知道要加载哪个应用程序标记

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

对于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.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。那套在哪里?