javascript - iOS Chrome 和 AngularJS 不执行 HEAD 中的 Controller

标签 javascript ios angularjs google-chrome

这种情况仅发生在 iOS 版 Chrome 中。 我在 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 无法在 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';


}]);

感谢您的建议。

最佳答案

您的 View 文件中有拼写错误。应该是:

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

不是

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

关于javascript - iOS Chrome 和 AngularJS 不执行 HEAD 中的 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28366865/

相关文章:

javascript - SailsJS : POST requests are not resolved properly when invoking req. param() 和 req.file()

javascript - NodeJS/ExpressJS/MongoDB 简单 API 错误

ios - 使用 Vim 代替(或与)Xcode 进行 iOS 开发

objective-c - 如何在NSString中使用文本和变量的组合?

html - 单击外部时如何隐藏 uib-popover

javascript - 无法访问窗口/全局变量 - 似乎未定义

javascript - 在 Typescript 中访问对象类的静态方法?

ios - 如何快速安装和使用CocoaAsyncSocket

javascript - Angular 指令不工作 Chrome 打包应用程序

javascript - 将用户选择的多个单选按钮选项存储在使用 ng-repeat 构建的 Angular js 中