I have 2 variables that manipulate the same image
In the html:
<i class="fa fa-trash-o" aria-hidden="true" ng-click="vm.deleteMessage()" ng-show="!vm.instance.deleted" ng-show="!vm.flagDelete"></i>
but it never changes, what is my error?
I have 2 variables that manipulate the same image
In the html:
<i class="fa fa-trash-o" aria-hidden="true" ng-click="vm.deleteMessage()" ng-show="!vm.instance.deleted" ng-show="!vm.flagDelete"></i>
but it never changes, what is my error?
I'll give you an example if it helps you in plunkr how to make it show or not:
Controller: As you can see, here I use controller as:
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
var vm = this;
vm.mostrar = true;
vm.cambiarEstado = function(){
vm.mostrar = !vm.mostrar;
}
});
Html: here I also use controllerAs:
<body ng-controller="MainCtrl as mainCtrl">
<p ng-show='mainCtrl.mostrar'>Parrafo uno</p>
<p ng-show='!mainCtrl.mostrar'>Parrafo dos</p>
<button ng-click="mainCtrl.cambiarEstado()">A traves de funcion</button>
<button ng-click="mainCtrl.mostrar = !mainCtrl.mostrar">Desde el htmln</button>
</body>
In addition to this, I added two ways to change the value of the variable that controls visibility.
Another thing that I notice in your code is that you have double ng-show, you only have to have one, and in case of responding to two variables you should do the following:
ng-show="var1 && var2"
or
ng-show="var || var2"
or
ng-show="fncRetornaValor()"
I hope it's what you're looking for, anything you ask again.