javascript - Ionic, hide and show element from side menu -
i new ionic. need hide elements side menu. example html markup:
<ion-side-menus enable-menu-with-back-views="false"> <ion-side-menu-content> <ion-nav-bar class="bar-stable"> <ion-nav-back-button> </ion-nav-back-button> <ion-nav-buttons side="left"> <button class="button button-icon button-clear ion-navicon" menu-toggle="left"> </button> </ion-nav-buttons> </ion-nav-bar> <ion-nav-view name="menucontent"></ion-nav-view> </ion-side-menu-content> <ion-side-menu side="left"> <ion-header-bar class="bar-stable"> <h1 class="title">menĂ¼</h1> </ion-header-bar> <ion-content> <ion-list> <ion-item menu-close ng-click="login()"> login </ion-item> <div ng-show="myvalue"> <ion-item id="idsuchen" menu-close href="#/app/suche"> suchen </ion-item> </div> </ion-list> </ion-content> </ion-side-menu> </ion-side-menus>
i try hide , show ion-item.
my controller (javascript) code :
angular.module('starter.controllers', ['ngcordova']) .controller('appctrl', function($scope, $ionicmodal, $timeout,$ionicsidemenudelegate) { // form data login modal $scope.logindata = {}; // create login modal use later $ionicmodal.fromtemplateurl('templates/login.html', { scope: $scope }).then(function(modal) { $scope.modal = modal; }); // triggered in login modal close $scope.closelogin = function() { $scope.modal.hide(); }; // important part. $scope.logout = function() { alert("logout"); $ionicsidemenudelegate.scope.myvalue = false; // have add }; // perform login action when user submits login form $scope.dologin = function() { console.log('doing login', $scope.logindata); $timeout(function() { $scope.closelogin(); }, 1000); }; })// ende
i tried this. if click on button "logout" ion-element hide. not working.
syntax tried :
$ionicsidemenudelegate.scope.myvalue = false; $ionicsidemenudelegate.scope.myvalue = true; $scope.myvalue = true; $scope.myvalue = false;
it works jquery using hide $('#idabmelden').hidde();
if hide once can't show again. weird.
thanks in advance
the code above little hard navigate, want like:
in html:
<a ng-click="togglesomething()">clickme</a> <div ng-show="isvisible"><h1>toggle me</h1></div>
js: in init block:
// initial state visible var initial_state = true; $scope.isvisible = initial_state;
js - toggle/onclick function
// toggle value $scope.togglesomething = function(){ $scope.isvisible = !$scope.isvisible; console.log('make sure togglesomething() firing*'); }
Comments
Post a Comment