iOS Chrome和AngularJS不会在HEAD中执行控制器

时间:2015-02-06 13:28:20

标签: javascript ios angularjs google-chrome

仅在Chrome for iOS中发生。 我在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>

问题是headCrtl没有在Chrome for iOS中执行。

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';


}]);

感谢您的任何建议。

1 个答案:

答案 0 :(得分:0)

您的视图文件中有拼写错误。它应该是:

<head ng-controller="headCtrl as head">

<head ng-conroller="headCtrl as head">