0

I use the ng-select angular library https://github.com/ng-select/ng-select with angular7. Is it possible to open the native list on mobile device as a real select tag ? For example :

<select id="cars" name="cars">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="fiat">Fiat</option>
  <option value="audi">Audi</option>
</select>

Thanks,

clement
  • 489
  • 1
  • 5
  • 18
  • So you don't want ng-select styles and functionality in mobile devices right? – prathameshk73 May 25 '20 at 11:24
  • actually yes :) maybe I have to code something else for mobile device finally... Well, is there a way to be sure that my visitor is on a mobile device ? – clement May 26 '20 at 07:28

1 Answers1

0

You can apply ng-select only if you have target device as desktop. For mobile devices just show native select. Try below function to detect mobile device.

 function getDevice() {
         var ua = navigator.userAgent;
         return (ua.indexOf('iPhone') != -1) ? 'iphone' : ((ua.indexOf('iPad') != -1) ? 'ipad' :       ((ua.indexOf('Android') != -1) ? 'android' : 'desktop'));
}

console.log('You are using', getDevice())
prathameshk73
  • 1,048
  • 1
  • 5
  • 16