Re: [AngularJS] ng-switch-when != null

6,295 views
Skip to first unread message

Witold Szczerba

unread,
Dec 10, 2012, 6:11:11 PM12/10/12
to ang...@googlegroups.com

You can try this:
<div ng-switch on="!!foo.bar">
<div ng-switch-when="true">
  ...
</div>
<div ng-switch-default>...</div>
</div>

Regards,
Witold Szczerba
---
Sent from my mobile phone.

On Dec 10, 2012 8:28 PM, <guru.th...@gmail.com> wrote:
Is something like this possible in angularjs?

<div ng-switch-on="foo.bar">
  <div ng-switch-when="{{!null}}">
    //when not null, display this div
  </div>
  <div ng-switch-default>
    //by default, display an empty div
  </div>
</div>

What do I need to set ng-switch-when to in order to produce the desired behavior?

Thanks!

Arsen.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
 
 

finish...@yahoo.com

unread,
Dec 11, 2012, 10:13:22 AM12/11/12
to ang...@googlegroups.com
Nice idea!

I will test it out later.

I wrote a small function that does the logic, but if the syntax you suggest is possible, it would eliminate some boilerplate code for such simple cases.

Arsen.

guy mograbi

unread,
Apr 9, 2013, 6:39:28 AM4/9/13
to ang...@googlegroups.com
G E N I U S

Ray Shan

unread,
Jul 9, 2014, 3:25:20 AM7/9/14
to ang...@googlegroups.com
Came to say THANK YOU, this is very clever.
Reply all
Reply to author
Forward
0 new messages