简体   繁体   English

在Angular中,如何从组件模板周围删除选择器标签?

[英]In Angular, how to remove the selector tag from around the component's template?

In Angular, how to remove the selector tag from around the component's template? 在Angular中,如何从组件模板周围删除选择器标签? It is making problems for browser to display the <td> fields within the component. 浏览器在显示组件内的<td>字段时出现了问题。 I have many instances of <tr> and each one has the first <td> styled differently: 我有许多<tr>实例,每个实例的第一个<td>样式都不同:

<tr>
  <td>1.1</td><td>1.2</td>
        <app-summary-data-row [data]="data[1]">
        </app-summary-data-row>
    </tr>
    <tr>
            <td colspan=2>2</td>
            <app-summary-data-row [data]="data[2]">
            </app-summary-data-row>
        </tr>

But, the majority set of <td> follows the same pattern, so I want to make the into the same template. 但是,大多数<td>遵循相同的模式,因此我想将其设为相同的模板。 The trouble is the angular's tags, that distort the construct of the table. 麻烦的是角度的标签,这会使表格的结构变形。

You can use the attribute selector instead in @component decorator:- 您可以在@component装饰器中使用属性选择器:-

@Component({
  selector: '[component-name]'
  ...
})

And then use it as:- 然后将其用作:-

<div component-name>
  ...
</div>

As per the documentation:- 根据文档:

You can Specify a CSS selector that identifies this directive within a template. 您可以指定一个CSS选择器,以在模板中标识此伪指令。 Supported selectors include element, [attribute], .class, and :not(). 受支持的选择器包括元素,[属性] 、. class和:not()。

Does not support parent-child relationship selectors. 不支持父子关系选择器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM