0
I have a controller to add an object and it uses the view. addObject.html
I have another controller that is to edit this object, and when accessing it it fills the whole view addObject.html.
What would be different would be just the buttonhole that would depend on "Edit" or "Add"
I created a variable in the named controller $rootScope.buttonCtrl
.
In which to access the addObjetoCtrl
the variable had value $rootScope.buttonCtrl = true;
And where to access the editObjetoCtrl
the variable had value $rootScope.buttonCtrl = false;
And in the view I have
<button type="button" ng-click="addTarefa()" ng-show="buttonCtrl"
class="btn btn-default" ng-disabled="tarefa.titulo == null ||
tarefa.descricao == null || cl.classe==null">
Cadastrar
</button>
<button type="button" ng-click="editarTarefa()" ng-show="buttonCtrl == false"
class="btn btn-default" ng-disabled="tarefa.titulo == null ||
tarefa.descricao==null || cl.classe==null ">
Editar
</button>
But what happens is that in view the value of buttonCtrl is always being true
, so only the "Register" button is showing up. What can be?
Did you start your variable as "false"? You entered the Edit page and it doesn’t even appear like that?
– PauloHDSousa
You can print on the screen the value of
buttonCtrl
and check if he’s really correct on the two calls?– Jéf Bueno