【问题标题】:ng-style or style in ion-nav-view not getting value from controllerion-nav-view 中的 ng-style 或 style 没有从控制器中获得价值
【发布时间】:2016-10-18 07:08:56
【问题描述】:

我正在使用 ionic 制作一个 hbrid 应用程序,但遇到了以下问题。我都试过了

<ion-nav-view ng-style="winHeight"></ion-nav-view>

<ion-nav-view style="{{winHeight}}"></ion-nav-view>

但是这些都没有从我的控制器中获得价值

if (!angular.isArray(data)) {
    $scope.winHeight = 'height: ' + ($window.innerHeight - 40) + 'px !important';
} else {
    $scope.winHeight = 'height: ' + ($window.innerHeight) + 'px !important';
}

console.log($scope.winHeight);

console.log 给了我正确的文本,但是当我加载和检查元素时,我看到的都是

<ion-nav-view ng-style="winHeight" class="view-container" nav-view-transition="ios" nav-view-direction="none" nav-swipe="">

<ion-nav-view style="{{winHeight}}" class="view-container" nav-view-transition="ios" nav-view-direction="none" nav-swipe="">

当我改为写作时

<ion-nav-view style="height:528px !important;"></ion-nav-view>

它像我想要的那样工作,但它不是动态的。有谁知道我做错了什么?

【问题讨论】:

    标签: javascript css angularjs ionic-framework ng-style


    【解决方案1】:

    它应该是 ng-style 应该是 JSON & 只是从 winHeight 变量传递高度值

    <ion-nav-view ng-style="{height: winHeight}"></ion-nav-view>
    

    代码

    if (!angular.isArray(data)) {
        $scope.winHeight = ($window.innerHeight - 40) + ' px !important';
    } else {
        $scope.winHeight =($window.innerHeight) + 'px !important';
    }
    

    【讨论】:

    • 抱歉,这不起作用。检查元素给了我&lt;ion-nav-view ng-style="{height: winHeight}" class="view-container" nav-view-transition="ios" nav-view-direction="none" nav-swipe=""&gt;
    猜你喜欢
    • 1970-01-01
    • 2017-01-05
    • 1970-01-01
    • 2016-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多