Angularjs 動(dòng)態(tài)改變title標(biāo)題(兼容ios)
廢話不多說(shuō)了,直接給大家貼代碼了,具體代碼如下所示:
<pre name="code" class="javascript">angular.module('myApp.loginCtrl', []) .config(function($httpProvider) { $httpProvider.defaults.headers.post['Content-Type']='application/x-www-form-urlencoded;charset=utf-8'; //改變header中content-type的格式 }) .controller('loginCtrl',['$scope','$http',function($scope,$http){}]) //兼容ios動(dòng)態(tài)改變title標(biāo)題 .run(['$location','$rootScope',function($location, $rootScope){ $rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) { $rootScope.title = toState.title }); $rootScope.$watch('title',function(title){ var body = document.getElementsByTagName('body')[0]; document.title = title; var iframe = document.createElement("iframe"); iframe.title = '登陸'; iframe.width = 0; iframe.height = 0; iframe.src = '//m.baidu.com/favicon.ico'; iframe.style.display = 'none'; iframe.addEventListener('load', function() { setTimeout(function() { // iframe.removeEventListener('load'); document.body.removeChild(iframe); }, 0); }); document.body.appendChild(iframe); }); }]); </pre><br> <br> <pre></pre> <pre code_snippet_id="2083087" snippet_file_name="blog_20161229_4_8475823" name="code" class="javascript">//路由<pre name="code" class="javascript"> .state('deliciousFood',{ title:'美食住宿', url:'/deliciousFood', templateUrl:'/hq/views/deliciousFood/deliciousFood.html', controller:'deliciousFoodCtrl', resolve:{ loadMyCtrl:['$ocLazyLoad',function($ocLazyLoad){ return $ocLazyLoad.load([ '/hq/views/deliciousFood/deliciousFoodCtrl.js', ]).then(function(){}) }] } })</pre><br> <pre></pre> <br> </pre>
以上所述是小編給大家介紹的Angularjs 動(dòng)態(tài)改變title標(biāo)題(兼容ios),希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
Angular.JS中select下拉框設(shè)置value的方法
select 是 AngularJS 預(yù)設(shè)的一組directive。下面這篇文章主要給大家介紹了關(guān)于Angular.JS中select下拉框設(shè)置value的方法,文中介紹的非常詳細(xì),對(duì)大家具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起看看吧。2017-06-06關(guān)于Angularjs中跨域設(shè)置白名單問(wèn)題
這篇文章主要介紹了Angularjs中關(guān)于跨域設(shè)置白名單問(wèn)題,需要的朋友可以參考下2018-04-04Angular.Js中ng-include指令的使用與實(shí)現(xiàn)
ng-include 指令用于包含外部的 HTML 文件。包含的內(nèi)容將作為指定元素的子節(jié)點(diǎn)。下面這篇文章主要給大家介紹了Angular.Js中ng-include指令的使用與實(shí)現(xiàn)的相關(guān)資料,文中介紹的非常詳細(xì),需要的朋友們下面來(lái)一起看看吧。2017-05-05詳解angular部署到iis出現(xiàn)404解決方案
這篇文章主要介紹了詳解angular部署到iis出現(xiàn)404解決方案,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-08-08Angular4綁定html內(nèi)容出現(xiàn)警告的處理方法
這篇文章主要給大家介紹了關(guān)于Angular4綁定html內(nèi)容出現(xiàn)警告的處理方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。2017-11-11Angular5中提取公共組件之radio list的實(shí)例代碼
這篇文章主要介紹了Angular5中提取公共組件之radio list的實(shí)例代碼,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-07-07