Class name that changes with different values and a pipe

Currently, I am integrating Weather Icons dynamically with a weather API and I am seeking to have the icons change dynamically rather than using a cumbersome switch statement with numerous options. However, I am encountering challenges when attempting to create SCSS classes dynamically.

<i [class]="'wi wi-day-' + '{{weather.daily.weathercode[0] | lowercase}}'"></i>
<i class="wi wi-day-thunderstorm" ></i>
"'wi wi-day-' + '{{weather.daily.weathercode[0] | lowercase}}'"

The second line showcases a thunderstorm icon, while the third line displays "'wi-wi-day-' + 'thunderstorm'". I am puzzled by why the first line did not function as expected in this scenario.

Answer №1

Avoid combining [] and {{}} notations:

Choose between:

<i class="wi wi-day-{{weather.daily.weathercode[0] | lowercase}}"></i>

or

<i [class]="'wi wi-day-' + (weather.daily.weathercode[0] | lowercase)"></i>

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

What is the most effective way to receive all values sent to an Observer upon a new subscription?

I have an observer that receives various values emitted to it at different times. For instance sub = new Subject<any>(); sub.next(1); sub.next(2); sub.next(3); #hack 1 sub.next(4); sub.next(5); sub.next(6); #hack 2 If there is a ...

Creating a triangle shape in the upper right corner with text using CSS

Starting my journey in HTML and CSS. This link shows how I want to use the code: .container { width: 250px; height: 250px; position:relative; background-color:grey; } .corner { width: 0; height: 0; border-top: 150px solid # ...

I currently have a CSS menu styled with the code below. Can you recommend the most effective method for centering the entire menu in the middle of the page

I am currently using CSS for a menu on my website. What is the best way to center the entire menu on the page? How can I adjust the menu items to appear in the center instead of on the left side? ul#css3menu1{ margin:0;list-style:none;padding:0;backgro ...

Converting HTML to Plain Text in Vue.js

Is there a way to convert HTML to plain text using vuejs? <ol> <li>The quick brown fox jumps over the lazy dog</li> <li>The quick brown fox jumps over the lazy dog</li> <li>The quick brown fox jumps over the ...

What is the best way to ensure that custom JavaScript and CSS files in Sphinx are always loaded with the most recent changes

Within the configuration file conf.py for Sphinx, I have specified the following: html_css_files = ['css/custom.css'] html_js_files = ['js/custom.js'] However, any alterations made to custom.js or custom.css do not immediately appear i ...

What method was used to incorporate a 2 pixel margin between the th elements on this website?

I've been analyzing the code thoroughly, but I am still unable to decipher how they managed to create a 2px margin between the th elements: The website in question is: Does anyone have any insights on this? ...

Tips for customizing the ion-alert header in Ionic framework

I have recently created an alert controller and am struggling to customize the appearance of the header within the alert popup. Despite going through the documentation, I have not been able to find a suitable solution. async customizeAlert(header, subHea ...

Set the side columns in CSS to have a fixed width, while the center content column should have

Check out this fiddle I created for everyone to view: http://jsfiddle.net/defaye/DhaHP/4/ For the full-screen result, click here: http://jsfiddle.net/defaye/DhaHP/4/embedded/result/ I'm encountering an issue where, after resizing the window past a ce ...

The symbol for expanding and collapsing sections in the Bootstrap accordion is not dynamically updating

I'm facing an issue with my bootstrap accordions. I have two accordions and each one has an inner accordion. The first one is set to be opened by default. However, when I click on the second accordion, the icon of the first one does not update to a pl ...

Implementing text overlays on images within a Bootstrap 4 navigation bar

I am struggling to grasp the flex structure in Bootstrap. I'm attempting to overlay text on an image within the navbar, but it seems the container of the navbar is causing issues. Perhaps my containers are not set up correctly. Any assistance would be ...

Can Bootswatch be installed using a package manager?

I have recently launched a small asp.net core website. Right now, all JS/CSS imports are from NPM and I am using webpack to bundle them together. Instead of sticking with the standard bootstrap template, I wanted to switch to bootswatch paper, but unfortu ...

Skeleton page CSS sub-navigation menu for Internet Explorer 7

I created a webpage using the Skeleton Framework and added a CSS menu with a submenu. While the menu works well in most browsers, I encountered issues with the submenu when using IE7 and lower versions. Instead of appearing below the parent menu item, the ...

Problems with alignment in Bootstrap4

I am currently using bootstrap 4 to style my website, and I am facing an alignment issue. I want my buttons to be aligned parallel to the date and time fields located above them. The Blue cross in the image indicates where my buttons are starting from, wh ...

`Looking for help with transitioning CSS to JavaScript`

I'm facing an issue that needs to be resolved. Please check out the link provided below. pop up modal This is the HTML code snippet.... <div class="wrap"> <a href="#modal-one" class="btn btn-big">Modal!</a> </div> <!- ...

Pressing the menu button will trigger a function that halts after the third click

As I attempted to implement the functionality of this left menu bar, I encountered a roadblock. The click event on the menu button seems to work fine initially - the left bar appears with the first click and closes as expected with the second click. Howeve ...

Applying font size constraints in TailwindCSS

Is it possible to implement the clamp() CSS function with TailwindCSS in order to create linear scaling for the fontSize within a defined range? I am specifically curious about how this can be integrated with Next.js. ...

Manage the number of items in each column using flexbox or grid layout strategy

Here's a similar situation .items { width: 100%; display: flex; align-items: center; justify-content: flex-start; flex-wrap: wrap; background: #cecece; padding: 10px; margin: 20px; } .item { height: 100%; flex: 0 0 calc(50% ...

How to package dependencies in an Angular 7 library without directly including them in the main application

In my Angular 7 project, I utilized the @angular/cli to set it up and then added a custom library using ng generate library. The application functions smoothly in dev mode without any issues. I made sure to isolate the dependencies relevant to the library ...

changing up the format of nested blockquotes

My website includes various text features, which means that nested blockquotes are a possibility. I am now curious if it is feasible to style nested blockquotes differently from each other! blockquote{ background-color:#666; color:#fff; border ...

Utilizing Bootstrap 4 with Angular 2 CLI

Currently, I am delving into the world of Angular2 CLI on my local server at http://localhost:4200/. Following the tutorial from , I have successfully installed Angular2. However, I encountered an issue while trying to import Bootstrap4 CSS. I attempted t ...