How to make a checkbox list appear bold when checked in AngularJS?

<div class='someClass'>
     <label ng-repeat="item in itemList">
           <input type='checkbox' checklist-model='itemCheckList' checklist-value='item.name'>
           <span class='label-text' ng-bind-html="item.name"></span>
     </label>
</div>

Looking for a way to dynamically change the font weight to bold when a checkbox is checked, and back to normal when unchecked. Any suggestions on how to achieve this? Much appreciated!

Answer №1

Is there a property on the item object that represents a boolean value, such as isChecked? For example, item.isChecked. If this property exists, you can utilize the ng-class directive in AngularJS.

// html 
 <span class='label-text' ng-class="{ 'selected': item.isChecked }" ng-bind-html="item.name"></span>

// css
.selected {
  font-weight: bold;
}

Answer №2

Implemented this code snippet in my CSS styling and saw immediate results.

input[type=checkbox]:checked + span.label-text{
     font-weight: bold;
}

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

Using ng-init within ng-repeat will only display the information of the final item

I'm looking to iterate through items in the following format: <section class="col-sm-4" data-ng-controller="PredictionsController" data-ng-init="findMyPredictions()"> <div class="games"> <div class="game-row" ng-repeat="pre ...

Navigating Tabs the AngularJS / Bootstrap Way: Best Practices

Looking to implement tab-based navigation for a website using AngularJS and Bootstrap in the most effective manner possible. So far, I've discovered that following the guidelines of the AngularJS Seed is considered the best approach for setting up an ...

Pausing the audio playback with a click of the mouse

As a beginner in front end development, I recently designed a simple website incorporating the Lightbox kit. One functionality I am currently working on is starting an audio track when a user clicks on a thumbnail image. However, I am seeking guidance on h ...

Outputting a variable using javascript

My challenge is to efficiently print the contract variable, which contains HTML content fetched from the server. How can I achieve this easily? I want the print window in Chrome to display the document with the contents of my variable when I click a button ...

Adjust the color of the bootstrap navbar upon resizing the screen

Attempting to modify the background color for the navbar menu items on smaller screen sizes. An issue arises in the following scenario: Browser window is resized until hamburger menu appears Hamburger menu is clicked to display menu i ...

Creating a Product Box design with CSS and incorporating visual elements

I have created a simple box design in Photoshop that I want to use to display product information. The box consists of a Header, Body, and Button, each as separate images. How can I assemble these elements using CSS/HTML? I only need the header text at th ...

Guide on retrieving the innerHTML of all <a> tags within a specific span class

<span class="mgen"> <a rel="tag">Action</a> <a rel="tag">Adventure</a> <a rel="tag">Apocalypse</a> <a rel="tag">Fantasy</a> <a rel="tag" ...

How can I generate a checkbox in a database with a field that allows for enabling and disabling?

I am looking to design a table that includes questions, checkboxes, and text boxes. All the questions are stored in a database and called through an array. In addition, I want to create disabled textboxes that become enabled when their corresponding checkb ...

Leverage angular-translate to establish placeholder text upon blurring

Just starting out with Angular and facing the challenge of implementing localization in my project. I have a lot of input fields that need their placeholders translated. In my HTML, I'm trying to achieve this: <input type="email" placeholder="{{ & ...

Leveraging CSS attribute selectors within JSX using TypeScript

With pure HTML/CSS, I can achieve the following: <div color="red"> red </div> <div color="yellow"> yellow </div> div[color="red"] { color: red; } div[color="yellow"] { color: yellow; ...

What is the best way to monitor for changes in a select dropdown value by a user using AngularJS?

I am facing a challenge with the following code snippet: <select data-ng-model="selectedTestAccount" data-ng-options="item.Id as item.Name for item in testAccounts"> <option value="">Select Account</option> </select> It has bee ...

What steps do I take to eliminate this additional content?

Currently working on a web messenger project and facing an issue with a specific bar that I want to remove from my interface: Within the Home.blade.php file, the code snippet looks like this: @extends('layouts.texter') @section('content&ap ...

What is the reason behind the vanishing of the input field while adjusting the

Why is the input field getting cut off when I resize my browser window, even though I'm using percentages? Here is a screenshot for reference: Shouldn't it resize automatically with percentages? Thank you! Below is my CSS code: body { margi ...

The typing library for Angular does not properly identify the JQueryStatic object

Encountered an issue with the Angular declaration file: Error TS2304: Cannot locate identifier 'JQueryStatic'. The typings for jQuery are installed and properly declare JQueryStatic as an interface. Looking for solutions to resolve this error. ...

Submitting a document on Android version 2.2.1 webview through an HTML form

I am currently working on an Android 2.2.1 app using a webview, and I am facing challenges with implementing a file upload feature. Despite having a standard file upload form, the browser box does not pop up when using webview. However, everything function ...

Trouble in connecting local CSS stylesheet

I am facing an issue with adding my .css file to my project. Even though I have tried various methods, the styles are not being applied properly. When I directly embed the style code in HTML, it seems to work fine. This leads me to believe that the proble ...

Steps for eliminating redundant lines in a CSS drop-down navigation bar

When looking at the following CSS code, I noticed that the bottom and top borders seem to overlap, creating a thick line. I'm having trouble figuring out how to remove it. Any suggestions or advice would be greatly appreciated. Thank you! HTML Code: ...

javascript ondrag while self-pressing

Within this div, I have a series of p elements. My goal is to drag the selected element into the input field. Here's an example: var input = document.getElementById("test"); input.addEventListener('drop', function (event) { event.pr ...

The unequal division of space between two flexed child divs is caused by varying image sizes

In my parent container, I have set the display property to flex. Inside, there are two divs with both having flex:1 set. However, the first child div contains an image and takes up twice as much space as the second div. If the screen is 1000px in height, ...

When using HTML and PHP, do note that the function mysql_fetch_array() requires the first parameter to be a resource and

I'm currently working on developing a feature for our website that allows users to search for banned usernames on our servers. The idea is to create a simple form where users can enter the username they want to check and then display any matching resu ...