Questions tagged [angularjs-ng-show]

The ngShow directive shows or hides the given HTML element based on the expression provided to the ngShow attribute.

From Angularjs documentation:

The ngShow directive shows or hides the given HTML element based on the expression provided to the ngShow attribute. The element is shown or hidden by removing or adding the .ng-hide CSS class onto the element. The .ng-hide CSS class is predefined in AngularJS and sets the display style to none (using an !important flag). For CSP mode please add angular-csp.css to your html file (see ngCsp).

171 questions
432
votes
12 answers

What is the difference between ng-if and ng-show/ng-hide

I'm trying to understand the difference between ng-if and ng-show/ng-hide, but they look the same to me. Is there a difference that I should keep in mind choosing to use one or the other?
Stephane Rolland
  • 38,876
  • 35
  • 121
  • 169
378
votes
10 answers

AngularJS ng-repeat handle empty list case

I thought this would be a very common thing, but I couldn't find how to handle it in AngularJS. Let's say I have a list of events and want to output them with AngularJS, then that's pretty easy:
60
votes
10 answers

How to check if a scope variable is undefined in AngularJS template?

How to check if a scope variable is undefined? This does not work:

Show this if $scope.foo == undefined

Sebastian Barth
  • 4,079
  • 7
  • 40
  • 59
25
votes
1 answer

AngularJS - using ng-show within ng-repeat

I'm having an issue using the ng-show directive within an ng-repeat block. The boolean value does not seem to be getting passed to ng-show correctly... To show what I mean, here is a screenshot of an example I made in JSFiddle: Here is some example…
11
votes
1 answer

Angular ng-show if string not empty does not work

I am writing a web app using AngularJS. The user submits up to 3 keywords to the server. I would like to show commas in between the keywords only if there are enough keywords. For example: if there are no keywords, then: if there is 1 keyword,…
9
votes
3 answers

Can ng-show directive be used with a delay

I have a spinner this is shown with ng-show="loading>0" Is there a way I can display this spinner with a delay (say 1 second)? I can't use a timeout because with multiple requests de loading counter will get out of sync. What I need is a delay on…
broersa
  • 1,656
  • 3
  • 16
  • 31
7
votes
3 answers

Display overview text when dropdown item is selected in AngularJS

I am looking to display an overview of each widget category to appear above the filtered results when that widget category is selected. I am assuming this will require a ng-show directive so will perhaps require some controller code too. But any…
me9867
  • 1,519
  • 4
  • 25
  • 53
5
votes
4 answers

Why does ng-mouseover not work with ng-if

I'm trying to use "ng-mouseover" directive on an image that has "ng-if" and it doesn't work but If I use "ng-show" directive it works, can everyone tell me why? Or it's an AngularJS problem? In the AngularJS documentation, I can't read anything…
Aitor
  • 455
  • 7
  • 17
5
votes
3 answers

Syntax error with ng-show: "token 'false' is at column {2} of the expression [{3}] starting at [{4}]"

I'm using ng-show as shown below: The value of entity.primary can be either true or false. I am getting the following error in the console: Syntax Error: Token 'false' is at column {2} of the expression…
forgottofly
  • 2,729
  • 11
  • 51
  • 93
5
votes
3 answers

ng-repeat: showing an item on click and hiding the others

I have a ng-repeat which display a list of divs and when I click on one it shows an aditionnal div for the clicked item. This is working
dekajoo
  • 2,024
  • 1
  • 25
  • 36
4
votes
3 answers

set all ng-if to false on click except clicked item

I have an ng-repeat which has a button that has a function that toggles an ng-show element inside that ng-repeat. The inside the class movie_option span has an ng-click=toggleInfo($index): And the div additional_info has an ng-show that shows or…
4
votes
4 answers

ng-Show not updating inside ng-repeat

I have the following …
3
votes
1 answer

ng-show in angularjs not working on span

I'm facing a problem with ng-show in Angularjs. I have a textbox where a user can enter the host name of a server. On entering this information, the hostname of the server gets sent to the backend system which verifies if the server exists or not. I…
3
votes
5 answers

Show div using Angular ng-show

I'm havings some problems with ng-show and $pristine. Here is the code (also on CodePen):

{{comment.rating}} Stars

Lyriene
  • 81
  • 1
  • 11
3
votes
2 answers

Accessibility of $index in ng-show

I try displaying a select when the previous select was checked.
1
2 3
11 12