Fade all list items other than the one that is selected

I have a group of items in a list. Whenever you click on an item, it expands to show more information. I would like all other items in the list to be blurred except for the one that is expanded.

<li href="#" class="list-group-item" ng-repeat="task in taskVm.tasksdata | orderBy: 'NAME' | filter: search | statusFilter: taskVm.statusArray">
  <div class="row" ng-click="task.isCollapsed = !task.isCollapsed">
    <div class="col-md-5">
      <lable>[[::task.NAME]]</lable>
    </div>
    <div class="col-md-5 offset-md-1">
      <lable ng-class="taskVm.getStateClass(task.STATUS)">[[::task.STATUS]]</lable>
    </div>
    <div class="col-md-2">
      <i ng-click="taskVm.openAlternativeTask(task)" class="fa fa-question-circle-o fa-stack-1x pull-right"></i>
    </div>
  </div>
  <div uib-collapse="task.isCollapsed">
    <hr>
    <div class="row">
      <lable>[[::task.MESSAGE]]</lable>
    </div>
    <div class="row">
      <div class="row" ng-hide="task.M.length ===0">
        <hr>
        <label>Alternatives</label>
      </div>
      <div class="row">
        <ul class="alternatives-list list-group">
          <li class="list-group-item" ng-repeat="alternative in task.M" ng-click="showAlternative(alternative.ID, alternative.SETNUMBER); taskVm.setSelected(alternative.SETNUMBER)" ng-class="{selected: alternative.SETNUMBER === taskVm.idSelectedVote}">[[alternative.SETNAME]]</li>
        </ul>
      </div>
    </div>
  </div>
</li>

These are the items in my list

Answer №1

To style all div elements except the first one within an ng-repeat, you can use the following code:

<div ng-class="{'test': !$first}"></div>

For a practical example and demonstration, refer to the working snippet below. This will guide you on how to apply similar functionality in your own code. By clicking on an item, only that specific item's class will be changed.

var myApp = angular.module('myApp',[]);
myApp.controller('MainCtrl', function($scope) {
  $scope.items = [
    { name: 'Item 1' },
    { name: 'Item 2' },
    { name: 'Item 3' },
    { name: 'Item 4' },
    { name: 'Item 5' }
    ];
    $scope.selected = 0;
    $scope.select= function(index) {
       $scope.selected = index; 
    };
});
.blur
{
  color:red;  
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
 <body ng-app="myApp" ng-controller="MainCtrl">
    <ul>
      <li ng-repeat="item in items track by $index">
        <a ng-click="select($index)" ng-class="{blur: $index == selected}">{{item.name}}</a>
      </li>
    </ul>
  </body>

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

Error: Compilation was unsuccessful due to module not found. Unable to resolve in ReactJS

As I was wrapping up this task, an unexpected error popped up: Module not found: Can't resolve './components/Post' in ./src/pages/index.js I've tried everything to troubleshoot it but no luck. Here's a rundown of my code snippets ...

The compatibility issue with Bootstrap Select 1.13.1 persists, despite being implemented alongside Bootstrap 4

This is a simple code example I tested using bootstrap-select: <html> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdnjs.cloud ...

Using Material UI, I have styled a typography element and a button to appear on the

Struggling to position a button and a <Typography> element side by side: Here's what I currently have: <Grid item lg={12} md={12} sm={12} xs={12} className={classes.register}> <Typography noWrap className={classes.typoText} varian ...

Aligning text of different sizes vertically in CSS

Struggling with a text line that contains multiple font sizes? Want all the text to align with the middle of the .line1 element? I tried using vertical-align:middle, but it's not working as expected. Check out the code on JSfiddle: http://jsfiddle.net ...

Can you recommend a resource that provides a comprehensive breakdown of which CSS elements are compatible with each internet

Can anyone recommend a comprehensive resource, such as a book or website, that provides a complete list of CSS elements and their compatibility with the major web browsers? Specifically, I am interested in information regarding compatibility with IE8 and F ...

Create multiple buttons with uniform width by adjusting padding in CSS

I recently attempted to create buttons using CSS and padding. Here is the HTML code for the buttons: <link rel="stylesheet" type="text/css" href="css/style-login.css" /> <link rel="stylesheet" type="text/css" href="css/font-awesome-4.0.3.css" /& ...

ng-map displays a portion of a map within the user interface

I'm currently using ng map and getting the UI for half of the screen, but not filling the entire div. Can someone please assist me with this issue? https://i.stack.imgur.com/u2CDn.jpg var app = angular.module('app', ['ngMap']); ...

One way to access the method `.name` in Angular 1.5 is by using the

I have been researching tutorials and documents, but I am having trouble understanding the code provided below. There are two pieces of code from two different files: one is the service file, and the other is the file where the service is imported. Here i ...

Is there a way to define the browser size before initiating my protractor test?

Below is a protractor test that is running smoothly. However, I need to incorporate some code that will open the browser in full screen mode as my test relies heavily on the precise pixel location of gridster tiles. How can I achieve this? describe(' ...

Angular animation will be triggered when the user clicks using ng-click

In my Angular project, I'm looking to implement an animation that will enlarge the size of an image. Below is the code snippet: <div class="card"> <div class="item images-parent"> <img src="img/carryout-icon.jpg" class="left-image" ...

Integration of AngularJS with PHP for Seamless User Authentication

As a newcomer to angularjs, I find the Login Process a bit confusing. Every time I log in, I'm automatically redirected to a specific page that is already set in the code. I just want a simple check to see if the user is logged in. If they are, then ...

Establish the API URL according to the configuration settings in the Web.config file

In the Angular application I inherited, the API URL is defined as a constant variable. While it works, it's tedious to change the variable value every time I need to switch between deployment, testing, and development APIs. Is there a way for me to a ...

What Is Preventing my Bootstrap Tabs from Displaying their Content?

I've been attempting to implement the nav-tabs feature from Bootstrap (version 5.2.2) into my Angular application. However, I've encountered an issue where only the content in the first tab is visible, while the contents of the other tabs remain ...

How can I ensure a div expands over another element when hovering the mouse?

I have a development div in the footer with a hover effect that expands it. However, it is currently growing underneath the top element on the site. I want it to expand on top or push the element above. Website: I've tried using position, float, and ...

Broken links - Dreamweaver CS4

Hello everyone - I am facing an issue with my rollover links not working correctly. I suspect it has something to do with the z-index and hidden divs. One example is the breadcrumbs: <div id="breadcrumbs"> <a href="#">Home &gt;&gt ...

Using inline-block can be effective on certain occasions

Hi everyone, I'm currently facing a puzzling issue and not sure what's causing it. Sometimes the elements I've set as inline-blocks cooperate as expected, but then when I refresh the browser, they suddenly decide to misbehave. Below is my ...

Delay the fading in of an element using jQuery

Is there a way to remove the pause between the images in my JavaScript/jQuery slideshow when fading in and out? I attempted using a small delay, but it still didn't eliminate the blank space. Any suggestions? Check out the code on jsfiddle: https://j ...

Adjust the width of the mosaic layout to a 50% / 50% ratio

I'm looking to adjust the layout so that each image occupies 50% of the page. Currently, one large image takes up 2/3 of the space and two smaller images take up the remaining 1/3. You can find the images here: To make the large image occupy 50%, yo ...

Blending AngularJs Widget with Adobe Captivate for Enhanced Interactivity

I've encountered an issue with integrating AngularJs into Adobe Captivate 8, and I'm starting to question the compatibility between AngularJs and Captivate. Despite having correct design setups in Captivate, I'm uncertain whether the error l ...

How to Update a Nested Document in Mongoose

I am currently working on a polls application using angular, express, and mongoose. Here is an overview of my data structure: var mongoose = require('mongoose'); var responseSchema = new mongoose.Schema({ responseText: String, votes: { ...