如何使用ionic.Platform

时间:2015-04-15 05:11:44

标签: ionic-framework ionic device-detection

我是使用ionic / AngularJS的新手,我想知道如何使用ionic.Platform打印当前设备。现在我有

var currentPlatform = ionic.Platform.platform();  

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

1 个答案:

答案 0 :(得分:7)

从您的控制器数据发送到视图使用应用程序模型$ scope ,意味着只需将您的变量分配给范围变量并直接在您调用控制器的位置获取它。

示例:

    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>

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

link1link2&amp; link3等。

希望这会对你有所帮助。