-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Too many ng-if 's #8721
Comments
you should be able to use |
@binarykitchen did this work for you? I think we can close this |
@caitp @binarykitchen this seems to be working correctly, at least in Chrome and FFox, guess we can close this one: http://plnkr.co/edit/tatbBjoS2sJr8Rrq4pIs?p=preview |
Yep, looks like it! @binarykitchen hope that helps |
Thanks folks, that's nice but my case is a bit more complicated. I have an video object here that can come with different combinations. Here an example for a JADE file with AngularJS together:
See, there is a |
@binarykitchen your example looks wired, you shouldn't have ng-if between ng-if-start / ng-if-end and for sure not ng-if and ng-if-end on the same node. In any case, try to put things in plunker if you need help, you can start with the one I've provided. |
Not really. I was just showing a real world example. I have a JavaScript object called videomail which sometimes has an subject, an url, a body etc. Hence the additional if (videomail) {
if (videomail.subject) {
}
if (videomail.url) {
}
if (videomail.body) {
}
} which is better and easier to maintain than if (videomail && videomail.subject) {
}
if (videoamail && videomail.url) {
}
if (videomail && videomail.body) {
} hope this helps to understand what I am after? |
@binarykitchen isn't that exactly this sort of construct? http://jsbin.com/wuxoquvogegu/1/ You can have nested "ifs", so that should work for you |
That's close but the last one line
will cause an empty p tag I don't want. That's why it would be great to allow something like this:
|
Yeah --- as mentioned in the issue I just opened, there's a way around this, but it's not currently implemented :( It wouldn't be too much of a refactoring to make that work, though, so will just have to see what Igor thinks about it. You might end up out of luck for supporting that, though. Does the extra node really hurt? why not just write a directive which removes it from the DOM? |
Thanks @caitp ! Well, I fancy clean HTML and do not want to leave unused tags behind. I think adding a directive to remove unnecessary DOM afterwards is only a temporary solution. I can wait until the refactoring is done. |
The point that I make is --- it's not clear that the refactoring will happen, because comment directives are a pretty rare use case and it doesn't really make sense to add another feature to them. But, since comments are basically just elements, it might not be unreasonable to support it. Will have to see what Igor thinks, but it's probably not a priority for 1.3 and is quite unlikely to make it into 1.2 |
Oh right, thanks for the clarification. All good. Will just watch this thread for now. |
Yeah just talked to Igor about it, as expected I don't think that's going to get fixed, so you're stuck with adding a directive to remove the wrapper nodes, or else just giving them a |
:( Alright, a directive then - how would you write such a directive? |
For my app I want to add lots of meta tags like that (in the jade template):
... and 20 more!
All of them should be shown if only one flag is set, namely
videomail.sent
.I think defining
data-ng-if="videomail.sent"
for each line is somewhat cumbersome.I wish there is a block element for the meta tags in the header. Something like that
But there is no such tag. But maybe you know a better workaround for that?
The text was updated successfully, but these errors were encountered: