1

I gotta a single question, I'm using ng-show and ng-hide to display options on a form based on a select option, however, when I submit my controller looks like this:

app.controller("MyCtrl", function($scope) {

   $scope.submit = function(event) {
       var element = event.currentTarget;
       //so when....
       console.log($(element).serialize());
   };


});

So when... I submit, all the elements appears even if the are hidden, I would like to display only those where ng-show is displayed.

Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299
andresmijares
  • 3,658
  • 4
  • 34
  • 40
  • 1
    You could use `ng-if` instead of `ng-show`/`ng-hide` – PSL Jan 13 '15 at 19:59
  • Unlike forum sites, we don't use "Thanks", or "Any help appreciated", or signatures on [so]. See "[Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). BTW, it's "Thanks in advance", not "Thanks in advanced". – John Saunders Jan 16 '15 at 04:30

1 Answers1

0

Instead of ng-show / ng-hide use ng-if. ng-if will render only those element which satisfy the expression inside ng-if attribute condition.

ng-if="expression"
Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299