ionic-framework - 如何使用ionic.Platform

标签 ionic-framework ionic device-detection

我对使用 ionic/AngularJS 很陌生,我想知道如何使用 ionic.Platform 来打印当前设备。现在我有

var currentPlatform = ionic.Platform.platform();  

在我的 main.html ctrl 中。有没有办法将它发送到 html 页面,或者我完全错误地接近它?

最佳答案

从您的 Controller 数据发送到查看使用 应用模型 $scope , 意味着只需将您的变量分配给范围变量,然后直接在您调用 Controller 的地方获取它。

示例:

    angular.module('scopeExample', ['ionic'])
    .controller('MyController', ['$scope', function($scope) {
          var currentPlatform = ionic.Platform.platform();  
          $scope.currentPlatform = currentPlatform;
    }]);

并在 查看 你访问
      <body ng-app="scopeExample">
        <ion-pane>
          <ion-header-bar class="bar-stable">
            <h1 class="title">Ionic Blank Starter</h1>
          </ion-header-bar>
          <ion-content ng-controller="MyController">
           {{currentPlatform }}
          </ion-content>
        </ion-pane>
      </body>

有关更多详细信息,请参阅以下链接:

link1 , link2 & link3等等。

希望这会帮助你。

关于ionic-framework - 如何使用ionic.Platform,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29642036/

相关文章:

css - ionic 可点击元素图标

php - 检测移动设备和平板设备

javascript - 使用 Javascript 或 HTML 检测 iOS 设备的型号?

css - 为手机加载不同的 CSS(但不适用于平板电脑)

javascript - ionic : How to make Angular Translate js working with Search Filter when language changed?

css - 为什么我的 Ionic 应用程序中的按钮会超出屏幕范围?

javascript - Angular 谷歌地图在组件加载时未定义经纬度

ionic :使用 scrollIntoView 时向上滚动停止

ionic platform add android-包名必须像: com. company.Name

angularjs - 如何使用 Protractor 识别 ionic 标签?