Using Onsen UI ons.platform isAndroidTablet()

266
August 13, 2017, at 2:33 PM

I'm working on simple hybrid app and I'm using Onsen UI using purely JavaScript, and everything is working good so far. The only issue I have is determining if the mobile device is a Tablet or Phone. I found ons.platform reference, and the isAndroidTablet() method, but I can't figure out how to use it. I used the <ons-if orientation="landscape"> and <ons-if platform="android"> to modify a few DOM elements when in landscape orientation and/or android, and it works great, but if I could use this isAndroidTablet() option, it would be great. I've been looking everywhere, but I can't find any documentation in addition to what's already on the Onsen UI pages. This is what I have so far:

 <ons-if orientation="landscape">
  <div id="overlay">
    <ons-scroller style="height:300px">
      <ons-list id="theList">
      </ons-list>
     </ons-scroller>
    <ons-if platform="android">I'm Android
   </ons-if>
  </div>
 </ons-if>

I would like to replace the <ons-if orientation="landscape"> with something like what isAndroidTablet() I guess should do. Anyone out there has had any experience with this? Thanks!

Answer 1

I have no experience with Onsen UI but from what I seen it's based on angular2(or react or vue). If you use angular, theoretically, you could use an *ngIf in your template.. Like a

<div *ngIf="isAndroidTablet()">...</div> 

Here you can find some template example with what I said earlier

READ ALSO
FirebaseUI. Populate recyclerview with a list of childs keys

FirebaseUI. Populate recyclerview with a list of childs keys

I'm trying to simplify my code and my firebase databaseTo do that, I need to populate my recyclerView with a list of the childs keys from my database

177
Android PhoneGap build issues

Android PhoneGap build issues

I built an app with PhoneGap for Android and got several issues when testing on my phone (Samsung; Android 51

165
Android eclipseLink jpa error

Android eclipseLink jpa error

Trying to use JPA(eclipseLInk 26

252
NDK porting c++ to android runtime fault

NDK porting c++ to android runtime fault

i'm new here, i was trying port c++ game server code from windows to android armeabi-v7a but i came across this alert from android ndk, the process should continue to run because it is a server:

255