我对使用 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/