This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
ngClass: Add support for conditional map in an array. #4807
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@bfanger - can you ensure that you have signed the CLA? |
I've just signed the "Google Individual Contributor License Agreement, v1.1" |
Rebased changes on v1.2.9 (makes travis-ci happy) |
I was just about to file a feature request for this! Is there something that could be done to make this more amenable to being merged? |
02dc2aa
to
fd2d6c0
Compare
cad9560
to
f294244
Compare
e8dc429
to
e83fab9
Compare
4dd5a20
to
998c61c
Compare
Any news on this? Thank you. |
@bfanger - OK, this is a reasonable feature. If you can add documentation for it we can try to get it into 1.4 otherwise it will slip to 1.5, I think |
Allows for ng-class expressions, like: <div ng-class=" [classVar, {'is-active': activeVar }] ">
Travis CI failed on 02f8020 (trailing whitespace) which was quickly fixed in 07d2a97 |
netman92
pushed a commit
to netman92/angular.js
that referenced
this pull request
Aug 8, 2015
This change allows `ngClass` expressions to have both objects and strings within an array: ```js $scope.classVar = 'nav-item'; $scope.activeVar = true; ``` ```html <div ng-class=" [classVar, {'is-active': activeVar }] "> ``` In this case, the CSS classes that will be added are: 'nav-item' and 'is-active'. Closes angular#4807
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allows for ng-class expressions, like:
Which allows a directive to apply classes it got via attributes in conjunction with conditional classes.
The current situation:
(Assuming classVar is set to "panel" and activeVar is true)
Using a map inside an array sets the class to
"panel [Object object]"
Using a map like
{classVar: true, 'is-active': activeVar }
would set the class to"classVar is-active"
instead of the desired"panel is-active"