使用$timeout()隐藏特定间隔后的页脚和页脚消息
Hide footer and footer message after particular interval using $timeout()
我正在尝试使用英特尔XDK
创建一个有角度的应用程序。在这里,当我运行索引页面时,我们可以看到页脚消息。我需要的是页脚和页脚消息将在5秒钟后使用timeout()隐藏。
但是我下面的代码不起作用。
index.html
<div class="bar bar-footer bar-balanced" style="background-color:#444444;">
<div class="title">{{footer_message}}</div>
</div>
app.js
app.controller('main', function ($scope,$interval,$timeout,$ionicModal,localStorageService,$http,$q,$templateCache) {
$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;
}
}
$scope.showFooter=function(){
$timeout(function () {
$scope.footer_message = null;
}, 5000);
}
$scope.showFooter();
}
I have created one example for you check this plunkr
http://plnkr.co/edit/PLTgJ2JraNOHAwNKk7iY?p=preview
为什么不给页脚一个Id,然后在超时中执行("#footerId").hide()
还希望您在控制器中添加$timeout
依赖项
如下更正,
<div class="bar bar-footer bar-balanced" ng-if="footer_message != 'null'" style="background-color:#444444;">
<div class="title">{{footer_message}}</div>
</div>
尝试对页脚div 使用ng隐藏
<div ng-hide="footer_message==null" class="bar bar-footer bar-balanced" style="background-color:#444444;">
<div class="title">{{footer_message}}</div>
</div>
代码一切正常。。。我尝试了$timeoutJs报价
angular.module('ExampleApp', [])
.controller('DemoController', function ($scope, $http, $q,$timeout) {
$timeout(function(){
$scope.footer_message=null;
},5000);
});
编辑1:Js报价
这是检查互联网连接的工作
if(navigator.onLine){
$scope.footer_message='success';
}
else{
$scope.footer_message=' no network ';
}
相关文章:
- Ajax聊天消息重复而不仅仅是更新
- 如果localstorage为空,则显示欢迎消息
- 绑定时将Parsley minlength消息作为选项传递时,未对其进行自定义
- 离开页面时弹出消息
- 有没有一种方法可以在控制台关闭的情况下让console.log()在IE中记录消息
- 消息显示之外的淘汰验证
- 选项卡侦听器未被来自后台脚本的消息激活
- jQuery在输入下验证post错误消息
- Scipt未在选定选项卡中执行以发送和接收消息
- 检查xmlhttprequest问题的消息
- AngularJs对ng消息的自定义替换
- ng消息仅在触摸时显示错误,并在错误的初始显示上转换
- 当用户按下回车键时,自动在text区域/text中插入消息
- 如果消息框答案为YES,则用Javascript填写表单
- 在javaservlet doPost方法中启动线程时,无法返回异常消息
- 解析云代码错误:解析.错误{代码:141,消息:“未调用成功/错误”}
- Node.js上的WebSocket,并在所有连接的客户端之间共享消息
- 在AngularJs中隐藏默认错误消息
- $timeout如何在angularJs中工作
- 使用$timeout()隐藏特定间隔后的页脚和页脚消息