我知道這方面有很多問題,但其中很多都是舊的(有些不再適用於新的Angular版本),而其他的則與什麼不相關我正在努力實現。加載ng-view之前的空白預加載器
基本上我有一個NG-視圖:
<main class="col-sm-9 offset-sm-3 col-md-10 offset-md-2 bg-body">
<div ng-view></div>
</main>
在我顯示與路由和諧音做了一個http.get
後的數據。正如標題中所寫,我希望在加載數據時在中心顯示一個空白(ng-view
)(頁面中有一個微調器(<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i>
))頁面。
我tryed一個指令,但似乎不工作:
AngularJS:
var app = angular.module('app', ['plangular','ngRoute', 'ngSanitize', 'slick']);
app.directive('loading', function() {
return {
restrict: 'E',
replace:true,
template: '<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i>',
link: function (scope, element, attr) {
scope.$watch('loading', function (val) {
if (val)
$(element).show();
else
$(element).hide();
});
}
}
});
HTML:
<main class="col-sm-9 offset-sm-3 col-md-10 offset-md-2 bg-body">
<loading></loading>
<div ng-view></div>
</main>
什麼可能是最好的方法?
哪裏出問題了?究竟發生了什麼? – SaiUnique
你是否得到裝載機? –
那麼,不知道爲什麼這不起作用(我忘了什麼?)...這是我的網站:http://new.wearegoingsolo.com/tracks/paperwhite-wash-us-away – GoingSolo