在angularjs中隐藏和显示带有页脚消息的页脚

Hide and show footer with footer message In angularjs

本文关键字:消息 显示 angularjs 隐藏      更新时间:2023-09-26

我正试图在英特尔XDK中创建一个有角度的应用程序,我在index.html中有3个页面脚本,有3个单独的页脚。我需要的是,当我运行每一页时,页脚和页脚消息将每5秒显示和隐藏一次

app.js

app.controller('main', function ($scope,$interval,$ionicModal,localStorageService,$http,$q,$templateCache) {
$scope.showFooter =true;
$scope.footer_message ='Powered By';
   $scope.checkConnection=function() {
            var networkState = navigator.connection.type;
            if(networkState == Connection.NONE){
                $scope.footer_message = "No Network Connection";
                return false;
            }else{
                $scope.footer_message = "Powered By";
                return true;
            }
        }
        $interval(function() {
            if($scope.showFooter)
            {
                $scope.showFooter =false;
            }
            else{
                $scope.showFooter =true;
            }
        },5000);
    });

index.html

我在index.html中有3页,3页有单独的3个页脚,如

<div class="bar bar-footer bar-balanced" style="background-color:#444444;">
                <div class="title">{{footer_message}}</div>
</div>

我试过这个例子,你需要添加ng-show来显示和隐藏数据更改时的页脚。

var app = angular.module("app",[]);
    app.controller('main', function ($scope,$interval) {
    $scope.showFooter =true;
    $scope.footer_message ='Powered By';    
        $interval(function() {
            if($scope.showFooter)
            {
                $scope.showFooter =false;
              console.log($scope.showFooter);
            }
            else{
                $scope.showFooter =true;
              console.log($scope.showFooter);
            }
        },5000);
    }); 

根据要求更改showFooter值。

<div class="bar bar-footer bar-balanced" style="background-color:#444444;" ng-controller="main" ng-show="showFooter">
   <div class="title">{{footer_message}}</div>
</div>