在angularjs中隐藏菜单30秒

时间:2022-07-10 02:49:09

I am trying to hide a menu for 30 seconds in angularjs and this is my attempt

我试图在angularjs中隐藏菜单30秒,这是我的尝试

.controller('MenuTimingController', function ($scope, $timeout) {
       $timeout(function () { $scope.loadAlertMessage = true; }, 30000);   
});

This is in the index file

这是在索引文件中

<div ng-controller="MenuTimingController"> 
                  <div ng-model="loadAlertMessage">
                <a menu-close ng-click="gotoMainPage()" style="color:black" ui-sref="entry" class="item"><i class="icon ion-android-contact"> Main Menu</i> </a></div></div>

But my challenge is that the menu is never hidden. Please where am I wrong. Any help is greatly appreciated.

但我的挑战是菜单永远不会隐藏。请问我哪里错了。任何帮助是极大的赞赏。

1 个解决方案

#1


0  

You can use ng-show or ng-hide to control the html element's visibility; and also , use the DOT magic.

您可以使用ng-show或ng-hide来控制html元素的可见性;而且,使用DOT魔法。

.controller('MenuTimingController', function ($scope, $timeout) {
   // init the $scope.show.loadAlertMessage
   $scope.show = {loadAlertMessage : false};
   $timeout(function () { $scope.show.loadAlertMessage = true; }, 30000);   
  });

  // the html code
  <div ng-show="show.loadAlertMessage">

#1


0  

You can use ng-show or ng-hide to control the html element's visibility; and also , use the DOT magic.

您可以使用ng-show或ng-hide来控制html元素的可见性;而且,使用DOT魔法。

.controller('MenuTimingController', function ($scope, $timeout) {
   // init the $scope.show.loadAlertMessage
   $scope.show = {loadAlertMessage : false};
   $timeout(function () { $scope.show.loadAlertMessage = true; }, 30000);   
  });

  // the html code
  <div ng-show="show.loadAlertMessage">