简体   繁体   中英

do not include elements into ng-hide on form serialize

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.

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM