Having trouble getting Sass extending to work in a basic scenario?

Here we have a simple example of Sass code, an Angular 2 component that accesses the Sass code, and the rendered HTML. However, there seems to be an issue with the blueBig span element in the last part. As someone new to Sass, I am not sure why this basic example is not extending properly. Could anyone provide some insights on this problem? Thank you!

Angular2 Component

@Component({
selector: 'test',
template: `
    <h1> testing sass</h1>
    <span [ngClass]="{blue : true}">This should be blue</span> 
    <br>
    <span [ngClass]="{big: true}">This should be big</span>
    <br>

    <span [ngClass]="{blue : true, big: true }">This should be big and blue</span>
    <br>
    <span [ngClass]="{blueBig : true}"> this should be big and blue as well</span>

`,
styleUrls: ['assets/scss/testing-component.scss']
})

Sass

.blue{
  color:blue;
}

.big{
  font-size: 200%;
}

.blueBig{
  @extend .blue;
  @extend .big;
}

HTML

https://i.stack.imgur.com/CrEud.png

Rendered HTML

https://i.stack.imgur.com/cXsBA.png

Answer №1

After compiling the Sass file on my local machine, it seems that everything is coded correctly.

My assumption, without seeing the actual HTML output, is that Angular might be converting camelcase blueBig to kebab-case blue-big. To address this issue, try wrapping the class name in quotes like this:

<span [ngClass]="{'blueBig' : true}">

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The importance of response headers in Angular

When I make a request from WP Rest Api in Angular, I encounter an issue that puzzles me. service.ts get(): Observable<any>{ return this.http.get<any>('mysite.com/posts?categories=4&per_page=2')); } app-component.ts ngOnInit ...

"Concealing a column in a PrimeNG data table with dynamic columns: A step-by-step

Hi, I'm looking for a way to hide a column in my PrimeNG data table. Is there an attribute that can be used to turn off columns in PrimeNG data tables? .Html <p-dataTable emptyMessage="{{tbldatamsg}}" [value]="dataset" scrollable="true" [style]=" ...

Incorporate an HTML code string into an Angular 2 template

I am working with HTML code stored in a Component variable, shown below: import { Component } from '@angular/core'; @Component({ selector: 'app-root', template: `Hi <div [innerHTML]="name"></div>`, styleUrls: [' ...

Efficiently Minimize Bootstrap Components Upon Clicking the Link

I've successfully created a navigation menu that expands and collapses without using a dropdown feature. However, I'm encountering an issue where I can't seem to toggle the div when clicking on a menu link. I attempted to use JavaScript to c ...

Aligning container divs at the center in various screen resolutions

I recently constructed a portfolio website using Bootstrap and Isotope JS. In my layout, I have a container div which works perfectly when viewed on a desktop browser - displaying 3 divs in one line. However, the issue arises when the resolution changes an ...

Flex layout in Angular is not able to adapt to content responsiveness

While the content of home.component.html is unresponsive and only displays some parts of the UI without scaling, when I directly place the code from home.component.html into app.component.html, it becomes responsive and functions perfectly. If anyone knows ...

What are the different ways to customize the indicator color of React Material UI Tabs using hex

Just got my hands on this amazing Material UI component <Tabs textColor="primary" indicatorColor="primary" > <Tab label="All Issues"/> </Tabs> The documentation states that indicatorColor and textColor can only be set to ' ...

Send a collection of objects by submitting a form

I have a component with the following html code. I am attempting to dynamically generate a form based on the number of selected elements, which can range from 0 to N. <form #form="ngForm" id="formGroupExampleInput"> <div class="col-xs-5 col-md- ...

Creating a sleek grayscale effect when hovering with CSS is both simple and effective

My website features a grayscale logo that smoothly transitions to color upon hover. However, I am experiencing some issues with the smoothness of this transition when using CSS. Here is my current code: <img alt="TT ltd logo" src="./img/tt-logo.png" c ...

Guide to creating a vertical handler that can be resized

Did you know that you can resize tables in http://www.jsfiddle.net? I'm curious about how to resize just the "Vertical Handler". Could someone share the source code with me? If possible, please provide an example on http://www.jsfiddle.net. ...

Is it possible to maintain the sidebar while eliminating the scrolling JavaScript?

Looking to recreate the image display style on Facebook where pictures appear in a lightbox format. The challenge I'm facing is figuring out how they manage to have the sidebar with no visible scroll bar inside... If you want to see this for yourself ...

The backend GET request functions properly on Postman, but fails to return any data to the frontend

When making a GET request and adding the creator as a parameter like api/watchlist/?creator=5dac9d3567aca81e40bfc0, all posts by that creator are returned in Postman with the following code: app.js app.get('/api/watchlist',(req, res, next)=&g ...

How to Use CSS to Align an Image in a Header

I'm struggling to position an image on the top right corner of my page, specifically in the header. Despite searching for help on Stack Overflow and other online resources, I can't seem to figure it out. Currently, here is what I have: The seco ...

Navigating through a custom drop-down using Selenium WebDriver: Identifying elements within DIV, UL, and LI

I need assistance automating a custom drop-down field that consists of DIV, UL, and LI elements. Select class or CSSSelector are not viable options due to the dynamic nature of the field. <div id="boundlist-1092" class="x-boundlist x-boundlist-floa ...

Transform your traditional sidebar into a sleek icon sidebar with Semantic UI

I am working on customizing the semantic-ui sidebar. My goal is to have it minimize to a labeled icon when the toggle button is clicked. However, I am having trouble with the animation and getting the content to be pulled when I minimize it to the labeled ...

Is it possible to designate a specific font family for italic font style and a different font family for regular font styles in VSCode?

Is it possible to use the "Operator Mono" font only for italic style and another font, such as "Fira Code," for other styles like bold, regular, semibold, etc. in VSCode? I attempted to change the font family to: "editor.fontFamily": "'Operator Mono ...

The text inside angular spans mysteriously vanishes

I have encountered an issue while working on my Angular Project. Previously, the <span> elements were displaying their contents without any problems. However, now I am facing an issue where the contents of <Span> elements are not visible. For ...

"Unlocking the Power of Ionic: A Guide to Detecting Status 302 URL Redirects

Trying to handle a http.post() request that results in a 302 redirect, but struggling to extract the redirected URL. Any tips on how to achieve this? Appreciate any help. ...

Looking for assistance with CSS | Implementing hover image with zoom effect

Currently, I have a page created using DIVI WordPress: My issue arises when attempting to implement a zoom effect on images upon hovering, as the image exceeds its designated div area. I attempted to utilize CSS code from this source: https://codepen.io/ ...

"Encountered an issue while attempting to scrape data from Rotten Tomatoes website

One of my tasks is to extract information from a webpage on Rotten Tomatoes. This is the screenshot of the page Based on the image, it seems that span class= descriptor is the parent class of a class, and div class = info director contains information ab ...