Can 2 parameters be sent in ng-show, angularjs?

0

In a view I have 2 div. At the beginning you should see one but when you click on a button this should hide and show the second div that is hidden at the beginning.

First div that should be displayed at the beginning

<div class="md-card-content" ng-controller="solicitudcomprasCtrl as showCase" ng-show="formVisibility">
</div>

Second div that at the beginning is hidden

<div id="div_agregarProducto" ng-show="agregarProducto">
</div>

Here the button

<a ng-show="formVisibility" ng-click="showCase.edit(showCase.item[' + data.id + '])"><i class="md-icon material-icons md-bg-teal-900 uk-text-contrast">&#xE32A;</i></a>

At the moment I can hide the div "formVisibility" being this the first div, in this way access to the edit function:

$scope.formVisibility     = true;
$scope.agregarProducto    = false;

              function edit(item){
              console.log("Ocultar Div");
              $scope.agregarProducto    = true;
              $scope.formVisibility     = false;
              $scope.item = item;  
            }

But I can not make it show the second div that is the "addProduct" since this action must be done with the same button, which another solution could apply

Thank you.

    
asked by JG_GJ 09.05.2017 в 05:47
source

1 answer

1

Try using the same variable for both. Only one waiting for a true and the other a false. That is to say in html:

Div 1:

<div class="md-card-content" ng-controller="solicitudcomprasCtrl as showCase" ng-show="formVisibility">
</div>

Div 2:

<div id="div_agregarProducto" ng-show="!formVisibility">
</div>

Controller:

$scope.formVisibility     = true;

              function edit(item){
             $scope.formVisibility = !$scope.formVisibility;  
            }

See if that is how you solve it.

    
answered by 09.05.2017 в 08:12