Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Angular after click add active class and remove from siblings

import { Output, EventEmitter } from '@angular/core';
@Output() itemSelectEvent= new EventEmitter<string>();

select(array_item){
itemSelectEvent.emit(array_item.id);
}

<app-item-desc *ngFor="let itemDesc of addedItem; let i = index" [itemlistDesc]="itemDesc" (itemSelectEvent)="selectEventHandler($event)"></app-item-desc>

selectEventHandler(event){
 // event, you will get selected id here
 for(let i=0;i < addedItem.length;i++){
   if(addedItem[i].id == event){
    addedItem[i]['is_active'] = true;
   }else{
    addedItem[i]['is_active'] = false;
   }
 }
}

<div class="order" (click)="select($event)" [ngClass]="{'active': itemlistDesc.is_active}">

</div>
Comment

angular click add class active and remove from others

<ul id="grouplist" class="list-group">
     <li class="list-group-item" [ngClass]="{'active': selectedItem == item}" (click)="listClick($event, item)" *ngFor="let item of groups">
        {{ item.name }}
     </li>
</ul>
Comment

angular click add class active and remove from others

listClick(event, newValue) {
    console.log(newValue);
    this.selectedItem = newValue;  // don't forget to update the model here
    // ... do other stuff here ...
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: angularjs Separate values in select containing 2 object 
Javascript :: Angularjs onchange datetime picker not working 
Javascript :: Porting Promise Chaining from AngularJs to VueJs 
Javascript :: set default value in dynamic dropdown angularjs 
Javascript :: how to use recursive function to select the parent in a tree array using angulat ui tree 
Javascript :: how to set a condition so that between the first and second mouse clicks there was a delay not 500mls 
Javascript :: How to map a JSON response with different indexes 
Javascript :: npx create-create-app movie-app 
Javascript :: react js graph with more than one y axis 
Javascript :: remove symbols from cnpj js 
Javascript :: gradient of a function 
Javascript :: how to build a nested, dynamic JSON in Go 
Javascript :: Node.js and Express session handling - Back button problem 
Javascript :: get copied text javascript 
Javascript :: TypeError: (intermediate value).addBooks is not a function in js 
Javascript :: Appium find Android Element with Xpath using Javascript 
Javascript :: Turn Module Into Non Module 
Javascript :: short-circuit evaluation , use of || operator 
Javascript :: Creating getLastBlock Object for blockchain 
Javascript :: ms dyn crm associate n:m record js 
Javascript :: jquery target all the li element using jquery 
Javascript :: Captalize all words first letter javascript 
Javascript :: JavaScript Using es6(ES2015) Destructuring assignment 
Javascript :: returning the outliers javascript array 
Javascript :: create object in jquery dynamically 
Javascript :: leetcode solution problem 66 plus one 
Javascript :: swal on submit angular with cancel butotn 
Javascript :: merge large arrays 
Javascript :: c# to javascript object 
Javascript :: how to check the validation of time in react datetime 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =