Skip to content

Instantly share code, notes, and snippets.

@azamanaza
Last active November 19, 2020 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azamanaza/a5ae7154a6c040b50c6899d7712bcd28 to your computer and use it in GitHub Desktop.
Save azamanaza/a5ae7154a6c040b50c6899d7712bcd28 to your computer and use it in GitHub Desktop.
Angular ::ng-deep is set for deprecation. Below is a workaround or a solution until encapsulation is final.
@Component({
selector: 'app-encapsulate',
templateUrl: './encapsulate.component.html',
styleUrls: ['./encapsulate.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class EncapsulateComponent implements OnInit {
constructor(el: ElementRef) {
const { nativeElement } = el;
nativeElement.className = nativeElement.tagName.toLowerCase();
// now in your scss, you can wrap everting in .app-encapsulate or whatever your compoenent's selector is.
}
}
@azamanaza
Copy link
Author

Src/watched issue: angular/angular#25160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment