[英]iOS Chrome and AngularJS does not execute controller in HEAD
That happens only in Chrome for iOS. 只有在适用于iOS的Chrome浏览器中才会发生这种情况。 I have something like that in html. 我在html中有类似的东西。
<html ng-app="MY_APP">
<head ng-conroller="headCtrl as head">
<title ng-bind="head.title"></title>
... libraries...
<link rel="stylesheet" type="text/css" ng-href="./css/{{ head.style }}.css"/>
</head>
<body ng-controller="mainCrtl as main">
</body>
</html>
The problem is that headCrtl does not executing in Chrome for iOS. 问题是headCrtl无法在iOS的Chrome浏览器中执行。
MY_APP.controller('headCtrl', ['$rootScope', '$scope', '$location', function ($rootScope, $scope, $location) {
var vm = this;
var host = $location.host();
if (host.indexOf('site1') > -1) {
vm.style = 'site1';
} else
if (host.indexOf('site2') > -1) {
vm.style = 'site2';
}
$rootScope.brandCode = vm.style;
vm.title = 'Straps';
}]);
Thank you for any advice. 感谢您的任何建议。
You have a typo in your view file. 您的视图文件中有错字。 It should be: 它应该是:
<head ng-controller="headCtrl as head">
not 不
<head ng-conroller="headCtrl as head">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.