我正在尝试使用英特尔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();
}
答案 0 :(得分:0)
为什么不给你的页脚一个ID,然后在超时时间("#footerId").hide()
还希望您在控制器中添加$timeout
依赖项
答案 1 :(得分:0)
如下所示纠正,
<div class="bar bar-footer bar-balanced" ng-if="footer_message != 'null'" style="background-color:#444444;">
<div class="title">{{footer_message}}</div>
</div>
答案 2 :(得分:0)
你的代码一切都很好...... 我在小提琴中尝试了$ timeout JsFiddle
angular.module('ExampleApp', [])
.controller('DemoController', function ($scope, $http, $q,$timeout) {
$timeout(function(){
$scope.footer_message=null;
},5000);
});
Edited1: JsFiddle
这是检查互联网连接的工作
if(navigator.onLine){
$scope.footer_message='success';
}
else{
$scope.footer_message=' no network ';
}
答案 3 :(得分:0)
尝试使用 ng-hide 作为页脚div
<div ng-hide="footer_message==null" class="bar bar-footer bar-balanced" style="background-color:#444444;">
<div class="title">{{footer_message}}</div>
</div>
答案 4 :(得分:0)
I have created one example for you check this plunkr
http://plnkr.co/edit/PLTgJ2JraNOHAwNKk7iY?p=preview