angularjs 1.8.2 in html template variable with ng-show not evaluated

189 Views Asked by At

I create a component with :

app.component('adminMenu',{

templateUrl:'../template/adminMenu.html',               
controller:function adminMenuController($rootScope){
  this.adminItems=[
    {link:'../admin/addbook',name:'Aggiugi Libro'},
    {link:'../admin/default',name:'Aggiungi Editore'},
     {link:'../admin/default',name:'Aggiungi Autore'},
     {link:'../admin/default',name:'Aggiungi Genere'},

  ];

  this.showAdminMenu= function showAdminMenu(){
    $rootScope.menuShowGeneri = true;
    $rootScope.showBestSeller=true;
   $rootScope.adminMenuHide2=!$rootScope.adminMenuHide2;

  };


}

and adminMenu.html template:

<li id="gestione_menuid"  >
    <a href="#"  ng-click="$ctrl.showAdminMenu()" class="menulink">Gestione Bookshop</a>
        <ul id="gestione_sottomenuid" ng-show="adminMenuHide2"   class="sottomenu0" >
            <li class="sottomenu1" ng-repeat="item in $ctrl.adminItems"  >
            <a href="{{item.link}}" class="menulink">{{item.name}}</a>
            </li>
        </ul>
</li>

and as run:

app.run(function ($rootScope) {
  $rootScope.menuShowGeneri = true;
  $rootScope.showBestSeller = true;
  $rootScope.adminMenuHide2 = true;
  $rootScope.errorDialogHide = true;


  $rootScope.errorMessage = "Errore generico!!";

});

the ng-show doesn't work?? it seem that adminMenuHide2 is not found ....this is work if I use controller inside the page without component....

0

There are 0 best solutions below