ng-hide if value is empty

24,841 views
Skip to first unread message

Heydon Pickering

unread,
Aug 21, 2012, 8:56:36 AM8/21/12
to ang...@googlegroups.com
Just a quick one:

How do I use ng-hide to hide an element if a value in my model is empty? I tried

<a href="#" ng-hide="modelValue == ''">Hidden if empty</a>


Sorry if this is a really simple one :-)

Alex Figueiredo

unread,
Aug 21, 2012, 11:10:40 AM8/21/12
to ang...@googlegroups.com

Anthony Bullard

unread,
Aug 21, 2012, 12:19:52 PM8/21/12
to ang...@googlegroups.com
I use for instance "$scope.user === NULL" when I need to hide parts of the user experience that's only for logged in users.

--
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.
 
 

Heydon Pickering

unread,
Aug 21, 2012, 12:30:56 PM8/21/12
to ang...@googlegroups.com
Thanks, fellas. Both work great :-)

Derek Eskens

unread,
Apr 7, 2013, 10:30:19 AM4/7/13
to ang...@googlegroups.com
How would you show/hide an elements based on a nested property in the model?  e.g. $scope.person.personId

Vishnudas Tekale Kulkarni

unread,
Aug 13, 2013, 10:35:44 AM8/13/13
to ang...@googlegroups.com
Works for me... Thanks.

James Klein

unread,
Apr 22, 2014, 6:25:36 AM4/22/14
to ang...@googlegroups.com
Worked perfectly. So simple haha. I was trying != null
Reply all
Reply to author
Forward
0 new messages