Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

255
Views
Cómo agregar SCSS a un componente de una biblioteca angular

Creé una biblioteca en angular 6. El problema es que no se aplica el estilo. Aquí está mi código:

micomponentepersonalizado.html

 <div class="cutom-div"> Hello </div>

mycustom.component.ts

 import { Component, OnInit } from "@angular/core"; @Component({ selector: "lib-mycustom", templateUrl: "./mycustom.component.html", styleUrls: ["./mycustom.component.scss"], }) export class MycustomComponent implements OnInit { constructor() {} ngOnInit() {} }

mycustom.component.scss

 .custom-div { background: red; height: 20px; }

Se suponía que esto iba a ser sencillo. Pero no se aplica estilo. Inspeccioné el elemento también:

ingrese la descripción de la imagen aquí

ingrese la descripción de la imagen aquí

¿Qué más me estoy perdiendo aquí? Por favor, señale mi error.

Estoy construyendo la biblioteca normalmente:

ng build my-library y luego cd dist\my-library>npm pack

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

https://angular.io/api/core/ViewEncapsulation#None

None significa que Angular no encapsula la vista. Angular agrega el CSS a los estilos globales. Las reglas de alcance, los aislamientos y las protecciones discutidas anteriormente no se aplican. Este modo es esencialmente el mismo que pegar los estilos del componente en el HTML.

 @Component({ selector: "lib-mycustom", templateUrl: "./mycustom.component.html", styleUrls: ["./mycustom.component.scss"], encapsulation: ViewEncapsulation.None, // <- This need use for global style })
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!