第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

ngRoute 如何添加loading

ngRoute 如何添加loading

眼眸繁星 2019-02-06 14:15:51
想在每個(gè)頁(yè)面圖片加載完之前添加一個(gè)loading,等到圖片加載完再顯示頁(yè)面,求思路
查看完整描述

2 回答

?
FFIVE

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超6個(gè)贊

(1)如果圖片是從后端請(qǐng)求獲取到的,可以在請(qǐng)求完成后設(shè)置一個(gè)布爾值的狀態(tài),在頁(yè)面里ngif判斷去顯示loading 或者圖片;

(2)如果圖片是從function 來(lái)寫(xiě)入,可以 function load(){} 完成后,同(1)去做;

(3)如果是html 里的image 標(biāo)簽,我不知道有事件可以判斷image加載完成,如果有好的方式,請(qǐng)回復(fù),共同學(xué)習(xí)。


查看完整回答
反對(duì) 回復(fù) 2019-02-25
?
翻閱古今

TA貢獻(xiàn)1780條經(jīng)驗(yàn) 獲得超5個(gè)贊

可以考慮使用angular 的攔截器機(jī)制,實(shí)現(xiàn)全局的請(qǐng)求攔截

//http loading Injector

app.factory('httpLoadingInjector',['$rootScope','$q',function($rootScope,$q) {

    var loadingInjector = {

        request: function(config) {


            $rootScope.httpLoading=true;

            return config;

        },


        response: function (response) {

            $rootScope.httpLoading=false;


            if(response.status!=200){

                console.log("Response-Error:",response);

            }


            return response;

        },

        responseError: function(err){


            // console.log('responseError:' + angular.toJson(err,true));


            // if(500 == err.status) {

            //     // 處理各類自定義錯(cuò)誤

            //     //$rootScope.httpLoading=false;

            //     msg("服務(wù)出問(wèn)題拉,聯(lián)系系統(tǒng)維護(hù)人員吧");


            //     console.log(err);



            // } else if(404 == err.status) {


            //     msg("服務(wù)找不到了,請(qǐng)聯(lián)系維護(hù)人員!")


            // }else if(403  == err.status) {

            //     msg("登錄狀態(tài)已過(guò)期,請(qǐng)重新登錄!",function () {

            //         logout();

            //     });


            // }else{

            //     msg("服務(wù)找不到了,請(qǐng)聯(lián)系維護(hù)人員!",function () {

            //        // logout();

            //     });


            // }



            $rootScope.httpLoading=false;

            return $q.reject(err);

        }

    };


    return loadingInjector;


}]);


最后在 app.config 中注入

$httpProvider.interceptors.push('httpLoadingInjector');




查看完整回答
反對(duì) 回復(fù) 2019-02-25
  • 2 回答
  • 0 關(guān)注
  • 438 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)