ng-class

Add a class selectively to an ng-repeat AngularJS

北城余情 提交于 2020-01-10 03:59:25
问题 I have an ng-repeat for a table, I want to be able to add a class when <td> is clicked, and remove the class when un-clicked. Multiple <td> can be selected at the same time. Right now ALL of the cities are or are not getting the class applies. For example: (lets say nodes has 100 items) <tr ng-repeat node in nodes> <td>{{node.name}}</td> <td>{{node.date}}</td> <td ng-click="toggleMe( node.city )" ng-class"{clicked : isClicked()}" >{{node.city}}</td> </tr> in my JS $scope.cityArr = []; $scope

AngularJS笔记3-- ng-show ng-class

旧城冷巷雨未停 提交于 2020-01-07 12:57:27
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> ng-show / ng-hide 通过绑定一个布尔型的变量,显示或隐藏HTML元素。 当 note.assignee为 true ( 也可以是非空字符串·,非0数字,非空JS对象等)时,assignee所对应的span元素可见。 ng-class 用于选择性的从HTML中添加或者删除CSS class . ng-class指令可接收字符串或对象作为参数 1.参数为字符串:直接把它作为CSS class名称应用到UI中 2 .参数是对象 ,angularJS会检查该对象的每一个属性及它所对应的值, 根据值是false 还是true来决定到底添加还是删除CSS class 本例:参数为对象,包含两个属性:当 note.done为true时,会添加名为 done的 css class 并删除 pending . 反之当note.done为false 时添加pending 删除done <!DOCTYPE html> <html ng-app="notesApp"> <head> <meta charset="UTF-8"> <title></title> <script src="js/angular.min.js"></script> <script src="js/jquery-3.1.1.min.js"><

有条件地申请课程的最佳方式是什么?

你说的曾经没有我的故事 提交于 2020-01-06 20:58:55
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 假设你有一个在 ul 呈现的数组,每个元素都有一个 li ,而控制器上的一个属性叫做 selectedIndex 。 什么是一类添加到最好的办法 li 与指数 selectedIndex 在AngularJS? 我目前正在复制(手动) li 代码并将类添加到其中一个 li 标签中,并使用 ng-show 和 ng-hide 仅显示每个索引一个 li 。 #1楼 我最近遇到了类似的问题,并决定只创建一个条件过滤器: angular.module('myFilters', []). /** * "if" filter * Simple filter useful for conditionally applying CSS classes and decouple * view from controller */ filter('if', function() { return function(input, value) { if (typeof(input) === 'string') { input = [input, '']; } return value? input[0] : input[1]; }; }); 它需要一个参数,它可以是一个2元素数组或一个字符串

Cannot create property 'selectedTest' on string 'test1' - problem with Angular

走远了吗. 提交于 2020-01-06 14:20:25
问题 I want to have multiply active buttons (if selected), and when I click on selected button, I want to remove active class (toggle). How can I do this? If I do it like below, I have error: ERROR TypeError: Cannot create property 'selectedTest' on string 'test1' hmtl <div class="btn-group"> <div class="btn btn-outline-secondary" *ngFor="let test of tests" (click)="selectTest(test)" [ngClass]="{active: isActiveTest(test)}"> {{test}} </div> </div> ts import { Component } from '@angular/core';

Ionic 4 ion-slides change css style of the active slide using ngClass

三世轮回 提交于 2020-01-03 02:24:13
问题 EDIT: adding a stackblitz: https://stackblitz.com/edit/ionic-b2r7si I am using ion-slides as following: <ion-slides class="fullWidth" [options]="slideOptsOne" #slideWithNav (ionSlideDidChange)="change($event)"> <ion-slide #status *ngFor="let array of arrays"> <ion-col> {{array}} </ion-col> </ion-slide> </ion-slides> I need to change the css style of the current active slide, like make it underlined or bold. I've done some researches and apparently I should use [ngClass]='' but can't know how.

Condition in ng- class not working

☆樱花仙子☆ 提交于 2020-01-03 00:18:13
问题 AngularJS I have scenario of applying class based on a condition in which I'm storing the value in rootscope dynamically and evaluating in html angular expression but still not working <li role="presentation" style="width:200px" ng-class="{active: true, inactive: false}[{{vm.$rootScope.currentPage}}==1]"><a href="#/create">Create</a></li> In inspect element if I check I can see 1==1 but still class is not getting active and if I remove {{vm.$rootScope.currentPage}} and place 1 it is working I

ng-animate with ng-class directive

馋奶兔 提交于 2019-12-31 08:48:28
问题 You can use ng-animate with ng-class with the add and remove animations. I'm looking to make one animation in CSS3 but haven't found good examples with ng-class online. So I was wondering if people have good examples they want to share. I am not sure what my final animation will look like, but for the purpose of this example let's say I just want to make the height of the div gradually increase when I add the class myclass . <div ng-class="{{myclass:scopeVar}}" ng-animate="?????"></div> **CSS

Complex angular js ng-class

∥☆過路亽.° 提交于 2019-12-29 11:46:36
问题 I have the component and have a problem setting the css class to it. I want it to always have a class of "box", then to have additional classes specified by the directive "class" argument and one conditional class "mini". Conceptually what I want to achieve is something like this: <div class="box {{class}}" data-ng-class="{mini: !isMaximized}"> ... </div> The problem is that when I set the class html attribute, the ng-class attribute is omitted. How to make my example work without changing

Active Class Based On Selected Menu

亡梦爱人 提交于 2019-12-25 03:55:22
问题 I'm learning angular and try to create a navbar menu and set 'active' class based on current page. index.html <html lang="en" data-ng-app="Afe" class="no-js"> <head> <!-- code omitted.. --> </head> <body> <nav class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container-fluid"> <div class="collapse navbar-collapse"> <ul class="nav navbar-nav" data-ng-init="activeMenu='AfeCoverPage'"> <li data-ng-class="{active: activeMenu=='AfeCoverPage'}" data-ng-click="activeMenu=

ngClass doesn't work Angular 5

有些话、适合烂在心里 提交于 2019-12-24 15:04:44
问题 Hello I am user angular 5 and I want to toggle change a Play <-> Pause icon for my soundcloud player. here is my TypeScript followed by my html. I can see in my console that I toggle correctly the playMode but the font awesome icon doesn't change as it is suppose to do. Thanks for the help. import { Ng2DeviceService } from 'ng2-device-detector'; import { Component, OnInit } from '@angular/core'; import { NgClass } from '@angular/common'; import './soundcloud-script.js'; @Component({ selector: