angular2viewencapsulation

Disabling effect of ViewEncapsulation.None in Angular

随声附和 提交于 2020-06-13 07:14:09
问题 How to disable the effect of ViewEncapsulation.None? E.g. One of my component (firstComponent) defines a css class with some properties. There is secondComponent which uses the same css class. I want my "secondComponent" to use the different specific values for properties defined by first component stylesheet. How can I achieve this? Note : I redefined the same class in "secondComponent" with different values, keeping the viewEncapsulation of secondComponent default. It didn't work for me.

How to access components unique encapsulation ID in Angular 9

让人想犯罪 __ 提交于 2020-02-22 04:19:50
问题 I'm trying to encapsulate my element ids by adding the instance id like this: <label for="id-{{ unique }}-name"></label> <input id="id-{{ unique }}-name" type="text" formControlName="name"> I previously worked with this: https://stackoverflow.com/a/40140762/12858538. But after upgrading Angular from 7 to 9 this seems deprecated. I was thinking about a simple helper service, which would generate unique ids for my app. Something like this: @Injectable() export class UniqueIdService { private

How to access components unique encapsulation ID in Angular 9

孤街醉人 提交于 2020-02-22 04:19:05
问题 I'm trying to encapsulate my element ids by adding the instance id like this: <label for="id-{{ unique }}-name"></label> <input id="id-{{ unique }}-name" type="text" formControlName="name"> I previously worked with this: https://stackoverflow.com/a/40140762/12858538. But after upgrading Angular from 7 to 9 this seems deprecated. I was thinking about a simple helper service, which would generate unique ids for my app. Something like this: @Injectable() export class UniqueIdService { private

How to overwrite angular-material2 styles?

試著忘記壹切 提交于 2019-12-21 05:38:16
问题 I'm using Angular2 with Material Design Components. And would like to overwrite some styles, but it looks like it's not possible because of ViewEncapsulation. Is it possible to switch off ViewEncapsulation (ViewEncapsulation.None) for 3rd party components? 回答1: I personally wouldn't touch the actual third party source ( like changing the encapsulation ) and reason is their style might mess up. But to handle this , I give you couple of solutions : 1-- Ugly : You can override whatever you want

How to change encapsulation of 3rd party component in Angular?

陌路散爱 提交于 2019-12-13 04:12:45
问题 I'm using AngularElements with native encapsulation so bs4 components can be used in bs3 project. Example: @Component({ selector: 'app-my-button', templateUrl: './my-button.component.html', encapsulation: ViewEncapsulation.Native, styles: ['@import "~bootstrap/scss/bootstrap.scss";'] }) export class MyButtonComponent {} The question is how to change encapsulation of 3rd party component so that global css doesn't affect it? Given NgbModalWindow component. How to change its encapsulation to

How to overwrite angular-material2 styles?

自作多情 提交于 2019-12-03 20:17:00
I'm using Angular2 with Material Design Components . And would like to overwrite some styles, but it looks like it's not possible because of ViewEncapsulation. Is it possible to switch off ViewEncapsulation (ViewEncapsulation.None) for 3rd party components? I personally wouldn't touch the actual third party source ( like changing the encapsulation ) and reason is their style might mess up. But to handle this , I give you couple of solutions : 1-- Ugly : You can override whatever you want from a component ( probably your top level component ) if it's viewEncapsulation is none . So go to your

Right way to override child component style from host component angular

浪子不回头ぞ 提交于 2019-11-28 14:07:34
What is the right way to override child component style from host component. I tried using encapsulation: ViewEncapsulation.None but i need to write the override stuff in style.sass file rather than host component. What should be the stackblitz If you have control on the child component code, you can define a customStyle input property: @Input() customStyle: {}; <div class="child-div" [ngStyle]="customStyle">I am the child</div> and pass it from the parent component: <app-child [customStyle]="style1"></app-child> style1 = { backgroundColor: "red", height: "150px" } See this stackblitz for a

Right way to override child component style from host component angular

喜欢而已 提交于 2019-11-27 08:05:29
问题 What is the right way to override child component style from host component. I tried using encapsulation: ViewEncapsulation.None but i need to write the override stuff in style.sass file rather than host component. What should be the stackblitz 回答1: If you have control on the child component code, you can define a customStyle input property: @Input() customStyle: {}; <div class="child-div" [ngStyle]="customStyle">I am the child</div> and pass it from the parent component: <app-child