2013-08-05 47 views
29

我想根據用戶正在查看的路線/頁面動態更新我的頁面的<title>。問題是,當頁面加載時,幾秒鐘後,它會在我的<title>標記內顯示{{title}},它將放入當前頁面的標題(從控制器加載)中。任何方式我都可以將{{title}}默認隱藏,直到加載該值爲止。如何在使用AngularJS時在<title>標籤中隱藏{{title}}?

+0

使用[NG-斗篷] [http://docs.angularjs.org/api/ng.directive:ngCloak]它適用於身體不知道這是否將在頭部 – Atrix1987

+10

工作ngCloak是一個CSS技巧,並且不會在''元素中工作。 – <span class="text-secondary"> <small> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/149341/">duskwuff</a></span> <span></span> </small> </span> </p> </div> </div> </div> </div> </div> </article> </div> <div class="answer-title"> <span class="text-logo margin-top-sm">A</span> <h2 class="title h4">回答</h2> </div> <div class="item-description text-md markdown-body margin-bottom-40 voidso"> <article class="board-top-1 padding-top-10"> <div class="post-col vote-info"> <span class="count">69<i class="fa fa-thumbs-up"></i></span> <i class="fa fa-check fa-2x"></i> </div> <div class="post-offset"> <div class="answer fmt"> <p>的<code class="prettyprint-override"><title></code>元素上使用<code class="prettyprint-override">ngBind</code>:</p> <pre><code class="prettyprint-override"><title ng-bind="title"> Default title </title> </code></pre> </div> <div class="post-info"> <div class="post-meta row"> <p class="text-secondary col-lg-6"> <span class="source"> <a rel="noopener" target="_blank" href="https://stackoverflow.com/q/18051435">來源</a> </span> </p> <p class="text-secondary col-lg-6"> <span class="float-right date"> <span>2013-08-05 05:55:59</span> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/149341/">duskwuff</a></span> </p> <p class="col-12"></p> <p class="col-12"></p></div> </div> <!-- comments --> <div class="comments"> <div itemprop="comment" class="post-comment"> <div class="row"> <div class="col-lg-1"><span class="text-secondary">+1</span></div> <div class="col-lg-11"> <p class="commenttext">謝謝。還有一件事,在我的控制器中,我需要將標題放在$ rootScope中,以便它顯示在<title>中,可能是因爲我稍後在div上使用了ng-view,而控制器僅限於它。有沒有其他方式讓控制器爲整個頁面設置它? – <span class="text-secondary"> <small> <span></span> </small> </span> </p> </div> </div> </div> <div itemprop="comment" class="post-comment"> <div class="row"> <div class="col-lg-1"><span class="text-secondary">+2</span></div> <div class="col-lg-11"> <p class="commenttext">知道這是舊的,但你可以在頁面的html元素上設置一個「ng-controller」屬性。 – <span class="text-secondary"> <small> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/2140807/">WillSeitz</a></span> <span></span> </small> </span> </p> </div> </div> </div> <div itemprop="comment" class="post-comment"> <div class="row"> <div class="col-lg-1"><span class="text-secondary">+0</span></div> <div class="col-lg-11"> <p class="commenttext">即精英.. – <span class="text-secondary"> <small> <span></span> </small> </span> </p> </div> </div> </div> </div> </div> </article> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6208739752673518" data-ad-slot="1038284119" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="clearfix"> </div> <div class="relative-box"> <div class="relative">相關問題</div> <ul class="relative_list"> <li> 1. <a href="http://hk.uwenku.com/question/p-givbufxq-vs.html" target="_blank" title="<meta name =「title」>標籤和<title></title>標籤"> <meta name =「title」>標籤和<title></title>標籤 </a> </li> <li> 2. <a href="http://hk.uwenku.com/question/p-hybfiqfh-beg.html" target="_blank" title="angularjs顯示/隱藏標籤"> angularjs顯示/隱藏標籤 </a> </li> <li> 3. <a href="http://hk.uwenku.com/question/p-qcfvrxjs-dz.html" target="_blank" title="如何隱藏<h4>標籤?"> 如何隱藏<h4>標籤? </a> </li> <li> 4. <a href="http://hk.uwenku.com/question/p-yksnlmye-ts.html" target="_blank" title="如何隱藏<標籤=「」> CSS"> 如何隱藏<標籤=「」> CSS </a> </li> <li> 5. <a href="http://hk.uwenku.com/question/p-txveahmk-bha.html" target="_blank" title="如何在asp:Repeater中隱藏div標籤"> 如何在asp:Repeater中隱藏div標籤 </a> </li> <li> 6. <a href="http://hk.uwenku.com/question/p-wlywoned-bew.html" target="_blank" title="如何在大餅中隱藏標籤"> 如何在大餅中隱藏標籤 </a> </li> <li> 7. <a href="http://hk.uwenku.com/question/p-saqklogk-bku.html" target="_blank" title="如何在asp.net中隱藏標籤"> 如何在asp.net中隱藏標籤 </a> </li> <li> 8. <a href="http://hk.uwenku.com/question/p-hmvzqyyd-bag.html" target="_blank" title="隱藏在標籤"> 隱藏在標籤 </a> </li> <li> 9. <a href="http://hk.uwenku.com/question/p-kunlilud-bhg.html" target="_blank" title="如何在使用Linq寫入XML時隱藏某些標籤?"> 如何在使用Linq寫入XML時隱藏某些標籤? </a> </li> <li> 10. <a href="http://hk.uwenku.com/question/p-yumvfpua-bbb.html" target="_blank" title="如何在使用actionbarsherlock時隱藏標籤?"> 如何在使用actionbarsherlock時隱藏標籤? </a> </li> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-6208739752673518" data-ad-slot="4606349252"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <li> 11. <a href="http://hk.uwenku.com/question/p-xbnicvus-bdn.html" target="_blank" title="在標籤中使用反應元素<title>"> 在標籤中使用反應元素<title> </a> </li> <li> 12. <a href="http://hk.uwenku.com/question/p-shiofyoh-gk.html" target="_blank" title="如何在沒有標籤時隱藏標籤容器?"> 如何在沒有標籤時隱藏標籤容器? </a> </li> <li> 13. <a href="http://hk.uwenku.com/question/p-mzafdria-tw.html" target="_blank" title="太多<title>標籤"> 太多<title>標籤 </a> </li> <li> 14. <a href="http://hk.uwenku.com/question/p-erddwotj-zz.html" target="_blank" title="如何編輯頁面<title>在Joomla 2.5中的標籤"> 如何編輯頁面<title>在Joomla 2.5中的標籤 </a> </li> <li> 15. <a href="http://hk.uwenku.com/question/p-vfamzbvc-vg.html" target="_blank" title="Rails:如何不在「<title>」標籤中逃脫"> Rails:如何不在「<title>」標籤中逃脫 </a> </li> <li> 16. <a href="http://hk.uwenku.com/question/p-drzgibeo-hp.html" target="_blank" title="將title標籤放在title =「」字段中"> 將title標籤放在title =「」字段中 </a> </li> <li> 17. <a href="http://hk.uwenku.com/question/p-cxpgvdun-xy.html" target="_blank" title="如何隱藏標籤使用代碼"> 如何隱藏標籤使用代碼 </a> </li> <li> 18. <a href="http://hk.uwenku.com/question/p-vxsvaqdn-br.html" target="_blank" title="如何使用Javascript隱藏標籤?"> 如何使用Javascript隱藏標籤? </a> </li> <li> 19. <a href="http://hk.uwenku.com/question/p-yhlrvzqp-zr.html" target="_blank" title="如何使用php隱藏div標籤"> 如何使用php隱藏div標籤 </a> </li> <li> 20. <a href="http://hk.uwenku.com/question/p-zdrptroc-vh.html" target="_blank" title="如何使用plugin,add_filter在wordpress中刪除或更改<title>標籤?"> 如何使用plugin,add_filter在wordpress中刪除或更改<title>標籤? </a> </li> <li> 21. <a href="http://hk.uwenku.com/question/p-ujtfmjvj-bhk.html" target="_blank" title="如何在JavaScript中使用div隱藏標籤?"> 如何在JavaScript中使用div隱藏標籤? </a> </li> <li> 22. <a href="http://hk.uwenku.com/question/p-zuiovuyi-ss.html" target="_blank" title="如何使用Javascript個性化<title>標籤?"> 如何使用Javascript個性化<title>標籤? </a> </li> <li> 23. <a href="http://hk.uwenku.com/question/p-ezqiafma-bbr.html" target="_blank" title="使用preg_replace函數來改變在PHP <title>標籤"> 使用preg_replace函數來改變在PHP <title>標籤 </a> </li> <li> 24. <a href="http://hk.uwenku.com/question/p-tlsmcgmy-bnv.html" target="_blank" title="在rails應用中隱藏標籤雲"> 在rails應用中隱藏標籤雲 </a> </li> <li> 25. <a href="http://hk.uwenku.com/question/p-gdvjpazq-zp.html" target="_blank" title="如何隱藏空標籤"> 如何隱藏空標籤 </a> </li> <li> 26. <a href="http://hk.uwenku.com/question/p-kkogoepk-bp.html" target="_blank" title="如何隱藏標籤?"> 如何隱藏標籤? </a> </li> <li> 27. <a href="http://hk.uwenku.com/question/p-hmzlzryi-bms.html" target="_blank" title="如何隱藏HTML標籤?"> 如何隱藏HTML標籤? </a> </li> <li> 28. <a href="http://hk.uwenku.com/question/p-pnpdrecb-bhc.html" target="_blank" title="{塊:標籤} +第n個孩子在<title>標籤"> {塊:標籤} +第n個孩子在<title>標籤 </a> </li> <li> 29. <a href="http://hk.uwenku.com/question/p-cjzoshzp-wu.html" target="_blank" title="如何在大寫字母<title>標籤"> 如何在大寫字母<title>標籤 </a> </li> <li> 30. <a href="http://hk.uwenku.com/question/p-xjtxqvai-bkn.html" target="_blank" title="如何在應用程序啓動時隱藏標籤"> 如何在應用程序啓動時隱藏標籤 </a> </li> </ul> </div> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-6208739752673518" data-ad-slot="1575177025"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div class="padding-top-10"></div> </div> </div> <script type="text/javascript" src="http://img.uwenku.com/uwenku/script/side.js?t=1644592048261"></script> <script type="text/javascript" src="http://img.uwenku.com/uwenku/plugin/highlight/highlight.pack.js"></script> <link href="http://img.uwenku.com/uwenku/plugin/highlight/styles/docco.css" media="screen" rel="stylesheet" type="text/css" /> <script type="text/javascript"> $('pre').each(function(i, e) { hljs.highlightBlock(e, "<span class='indent'> </span>", false) }); </script> <div class="col-lg-3 col-md-4 col-sm-5"> <div id="rightTop"> <div class="row"> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6208739752673518" data-ad-slot="5415218910" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div class="row sidebar panel panel-default"> <div class="panel-heading font-bold"> 最新問題 </div> <div class="m-b-sm m-t-sm clearfix"> <ul class="side_article_list"> <li class="side_article_list_item"> 1. <a href="http://hk.uwenku.com/question/p-bacwjvuk-bar.html" target="_blank" title="觸發器在oracle2中相乘兩列"> 觸發器在oracle2中相乘兩列 </a> </li> <li class="side_article_list_item"> 2. <a href="http://hk.uwenku.com/question/p-mikdcmvo-wt.html" target="_blank" title="紅寶石適用看跌數組"> 紅寶石適用看跌數組 </a> </li> <li class="side_article_list_item"> 3. <a href="http://hk.uwenku.com/question/p-ycuwofaj-xg.html" target="_blank" title="如何將目標中生成的內容部署到帶有MSBuild的UWP應用程序中的AppX包中"> 如何將目標中生成的內容部署到帶有MSBuild的UWP應用程序中的AppX包中 </a> </li> <li class="side_article_list_item"> 4. <a href="http://hk.uwenku.com/question/p-pkzsguhh-wz.html" target="_blank" title="SQL Server:CASE和連接字符串"> SQL Server:CASE和連接字符串 </a> </li> <li class="side_article_list_item"> 5. <a href="http://hk.uwenku.com/question/p-nipjwnwn-yy.html" target="_blank" title="爲什麼css網格在IE和Edge中不起作用?"> 爲什麼css網格在IE和Edge中不起作用? </a> </li> <li class="side_article_list_item"> 6. <a href="http://hk.uwenku.com/question/p-nqufrtsz-ze.html" target="_blank" title="保持html頁面內svg的大小"> 保持html頁面內svg的大小 </a> </li> <li class="side_article_list_item"> 7. <a href="http://hk.uwenku.com/question/p-ybfrlzqz-xw.html" target="_blank" title="在R中設置kmeans的靜態中心"> 在R中設置kmeans的靜態中心 </a> </li> <li class="side_article_list_item"> 8. <a href="http://hk.uwenku.com/question/p-obibwibz-xp.html" target="_blank" title="我怎樣才能在沒有警告的情況下設置一個很長的長號碼?"> 我怎樣才能在沒有警告的情況下設置一個很長的長號碼? </a> </li> <li class="side_article_list_item"> 9. <a href="http://hk.uwenku.com/question/p-fmboewhr-yc.html" target="_blank" title="如何更改jSpinners的ArrayList中的值?"> 如何更改jSpinners的ArrayList中的值? </a> </li> <li class="side_article_list_item"> 10. <a href="http://hk.uwenku.com/question/p-ryzljqmv-wn.html" target="_blank" title="提取數據"> 提取數據 </a> </li> </ul> </div> </div> </div> <p class="article-nav-bar"></p> <div class="row sidebar article-nav"> <div class="row box_white visible-sm visible-md visible-lg margin-zero"> <div class="top"> <h3 class="title"><i class="glyphicon glyphicon-th-list"></i> 相關問題</h3> </div> <div class="article-relative-content"> <ul class="side_article_list"> <li class="side_article_list_item"> 1. <a href="http://hk.uwenku.com/question/p-givbufxq-vs.html" target="_blank" title="<meta name =「title」>標籤和<title></title>標籤"> <meta name =「title」>標籤和<title></title>標籤 </a> </li> <li class="side_article_list_item"> 2. <a href="http://hk.uwenku.com/question/p-hybfiqfh-beg.html" target="_blank" title="angularjs顯示/隱藏標籤"> angularjs顯示/隱藏標籤 </a> </li> <li class="side_article_list_item"> 3. <a href="http://hk.uwenku.com/question/p-qcfvrxjs-dz.html" target="_blank" title="如何隱藏<h4>標籤?"> 如何隱藏<h4>標籤? </a> </li> <li class="side_article_list_item"> 4. <a href="http://hk.uwenku.com/question/p-yksnlmye-ts.html" target="_blank" title="如何隱藏<標籤=「」> CSS"> 如何隱藏<標籤=「」> CSS </a> </li> <li class="side_article_list_item"> 5. <a href="http://hk.uwenku.com/question/p-txveahmk-bha.html" target="_blank" title="如何在asp:Repeater中隱藏div標籤"> 如何在asp:Repeater中隱藏div標籤 </a> </li> <li class="side_article_list_item"> 6. <a href="http://hk.uwenku.com/question/p-wlywoned-bew.html" target="_blank" title="如何在大餅中隱藏標籤"> 如何在大餅中隱藏標籤 </a> </li> <li class="side_article_list_item"> 7. <a href="http://hk.uwenku.com/question/p-saqklogk-bku.html" target="_blank" title="如何在asp.net中隱藏標籤"> 如何在asp.net中隱藏標籤 </a> </li> <li class="side_article_list_item"> 8. <a href="http://hk.uwenku.com/question/p-hmvzqyyd-bag.html" target="_blank" title="隱藏在標籤"> 隱藏在標籤 </a> </li> <li class="side_article_list_item"> 9. <a href="http://hk.uwenku.com/question/p-kunlilud-bhg.html" target="_blank" title="如何在使用Linq寫入XML時隱藏某些標籤?"> 如何在使用Linq寫入XML時隱藏某些標籤? </a> </li> <li class="side_article_list_item"> 10. <a href="http://hk.uwenku.com/question/p-yumvfpua-bbb.html" target="_blank" title="如何在使用actionbarsherlock時隱藏標籤?"> 如何在使用actionbarsherlock時隱藏標籤? </a> </li> </ul> </div> </div> </div> </div> </div> </div> </div><!-- wrap end--> <!-- footer --> <footer id="footer"> <div class="bg-simple lt"> <div class="container"> <div class="row padder-v m-t"> <div class="col-xs-8"> <ul class="list-inline"> <li><a href="http://hk.uwenku.com/contact">聯系我們</a></li> <li>© 2020 HK.UWENKU.COM</li> <li><a target="_blank" href="https://beian.miit.gov.cn/">沪ICP备13005482号-4</a></li> <li><script type="text/javascript" src="https://v1.cnzz.com/z_stat.php?id=1280101193&web_id=1280101193"></script></li> <li><a href="http://www.uwenku.com/" target="_blank" title="优文库">简体中文</a></li> <li><a href="http://hk.uwenku.com/" target="_blank" title="優文庫">繁體中文</a></li> <li><a href="http://ru.uwenku.com/" target="_blank" title="поле вопросов и ответов">Русский</a></li> <li><a href="http://de.uwenku.com/" target="_blank" title="Frage - und - antwort - Park">Deutsch</a></li> <li><a href="http://es.uwenku.com/" target="_blank" title="Preguntas y respuestas">Español</a></li> <li><a href="http://hi.uwenku.com/" target="_blank" title="कार्यक्रम प्रश्न और उत्तर पार्क">हिन्दी</a></li> <li><a href="http://it.uwenku.com/" target="_blank" title="IL Programma di chiedere Park">Italiano</a></li> <li><a href="http://ja.uwenku.com/" target="_blank" title="プログラム問答園区">日本語</a></li> <li><a href="http://ko.uwenku.com/" target="_blank" title="프로그램 문답 단지">한국어</a></li> <li><a href="http://pl.uwenku.com/" target="_blank" title="program o park">Polski</a></li> <li><a href="http://tr.uwenku.com/" target="_blank" title="Program soru ve cevap parkı">Türkçe</a></li> <li><a href="http://vi.uwenku.com/" target="_blank" title="Đáp ứng viên">Tiếng Việt</a></li> <li><a href="http://fr.uwenku.com/" target="_blank" title="Programme interrogation Park">Française</a></li> </ul> </div> </div> </div> </div> </div> </footer> <!-- / footer --> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?f78a970f17b19a79fc477a3378096f29"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </body> </html>