What does _ngcontent-c# mean in Angular?

后端 未结 2 1589
灰色年华
灰色年华 2020-12-14 06:21

I\'m learning Angular 2/4 and I see the html tags with the ng generated attributes: _ngcontent-c0, _ngcontent-c1...

What does this c value mean?

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-14 06:24

    you can disable it by adding below import to your component,

    import {ViewEncapsulation} from '@angular/core';
    
    import { Component, OnInit } from '@angular/core';
    import { ViewEncapsulation } from '@angular/core';
    
    @Component({
      selector: 'app-dashboard',
      templateUrl: './dashboard.component.html',
      styleUrls: ['./dashboard.component.css'],
      encapsulation: ViewEncapsulation.None
    })
    export class DashboardComponent implements OnInit {
    
      constructor() { }
    
      ngOnInit() {
      }
    
    }
    

    please note this line :

     encapsulation: ViewEncapsulation.None
    

    make no addition of dynamic attribute from angular

提交回复
热议问题