-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feature(misc core): add ngId directive #7273
Conversation
Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
I'm getting a |
Okay, @caitp said it's not necessary to squash the commits into one, but I would at least put them into logical packages that remove all that c&p from existing code, WIP, logging etc. I'm not 100% sure, but you shouldn't need to run travis locally, it's done when you send a PR on github. |
Working on that now, didn't see the contribute docs before, was going off of the docs on the site. Travis is easier to run locally to spot the errors, rather than waiting for committing. I got it working now, though, I believe, I just need 0a6f332 to run. Thanks, @Narretz. |
caitp said it's not necessary to squash the commits into one before review, but I would at least put them into logical packages that remove all that c&p from existing code, WIP, logging etc. |
Renamed the PR, but it's probably not the same as in the dev docs. I'm no nearer to collapsing this; the issue is I merged in the recent version, and I don't know how to collapse some commits, then undo a merge, then collapse more. Should I just delete the PR, reset to the beginning, add all the changes in again in one commit, and reopen a PR? Seems to be the easiest option for me. |
How is this different from |
@RichardLitt , either create a new pull request or
|
Alright, got it. Thanks. @Wizek Basically, it does a couple of things more. It refuses to deal with space delimited strings, as those are invalid. It allows an object to be passed (with limits: if there are multiple truthy values, it only uses the key of the first one, much like {{a && 'aValue' || b && 'bValue' || 'cValue'}} might do, which is a workaround). If the {{variable}} evaluates as falsy, it removes the empty id class, as according to the html spec id must be a string of more than one character, and cannot be a boolean. @caitp raised a good point in that it is poor design to reflect state in an ID, as they should just represent nodes in the DOM. I agree. She also pointed out that this might be useful if there was an id generator for ngRepeat. I think that's a good point, and I think it's something that should be added onto this directive. Whether this is useful at the moment isn't clear, as it may equate the use of ngId as the same as that of ngClass, which shouldn't be done - ngClass should be used in almost all cases. Finally, I was hoping to be able to use $animate the same way that ngClass does, for transitions, but I'm not sure it's strictly necessary, as the id is simply replaced and not added and removed like classes can be, since multiple classes are valid. |
Add a way of dynamically updating the id attribute, using either a string or an object. Save the old id automatically in case the string or the object evaluates to falsy.
Travis failed due to cross browser tests not delineated in the documentation. I opened an issue here: #7303 |
02dc2aa
to
fd2d6c0
Compare
cad9560
to
f294244
Compare
e8dc429
to
e83fab9
Compare
4dd5a20
to
998c61c
Compare
Did you know that you can use
|
+1 @judytuna for mentioning |
With the possibility to use |
@lgalfaso using |
|
Word. |
Request Type: feature
How to reproduce:
Component(s): misc core
Impact: large
Complexity: medium
This issue is related to:
Detailed Description:
See below.
Other Comments:
There wasn't an ngId directive. While ngClass works a lot of the time - and ngClassOdd/Even and all of the $animate effects are incredibly useful - a directive that switches Ids would help with the way I configure Sass files, and would just be generally useful. I couldn't find any mention of an ngId directive around, probably due to poor google-fu, but here's a start.