[英]Angularjs How to make route async?
我正在使用route和ngView加載動態內容,並且得到警告:
不贊成在主線程上使用同步XMLHttpRequest,因為它會對最終用戶的體驗產生不利影響。 有關更多幫助,請訪問http://xhr.spec.whatwg.org/ 。
警告來自jQuery 2.1.3
如果我嘗試加載靜態html文件,則可以在沒有任何警告的情況下正常工作,無論如何,我可以使路由asyc嗎?
的app.config(函數($ routeProvider){
$routeProvider.when("/test", {
templateUrl: "/getStuff",
resolve:{
}
})
$routeProvider.otherwise({
templateUrl: "/test.html",
resolve:{
}
});
});
如果我嘗試加載靜態html文件,它會在沒有警告的情況下工作,如果templateUrl不是靜態html文件,則會出現警告
發現了問題! 這是因為我從網址返回的html包含
<link href="..." rel="stylesheet">
<link href="..." rel="stylesheet">
<script src="..."></script>
所以它在加載過程中發出請求,謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.