如何用简单的DIV标记替换指令Tag

时间:2016-09-26 15:09:14

标签: angular

有这个组件:

@Component({
  moduleId: module.id,
  selector: 'chart-cmp',
    template: ''
})
export class ChartComponent implements OnChanges {...}

和HTML模板

<chart-cmp style="min-width:310px; height: 400px; max-width: 800px; margin: 0 auto;"
        [typeId]="typeId" [username]="username" [grain]="grain"
        (onResult)="onResult($event)"></chart-cmp>

它生成HTML(dom)

 <chart-cmp style="min-width:310px; height: 400px; max-width: 800px;
 margin: 0 auto;" ng-reflect-type-id="elec" ng-reflect-username="JTAMISIER">
.... content...
</chart-cmp>

但我希望<DIV>代替<chart-cmp>

1 个答案:

答案 0 :(得分:2)

改为使用属性选择器:

selector: '[chart-cmp]',

<强> HTML

<div chart-cmp></div>