Category: pulgin

cordovaCamera ionic V1

  1.  install plugin
    • # cordova plugin add cordova-plugin-camera
  2. Code Control
    1. module.controller('PictureCtrl', function($scope, $cordovaCamera) {
      
        document.addEventListener("deviceready", function () {
      
          var options = {
            quality: 50,
            destinationType: Camera.DestinationType.DATA_URL,
            sourceType: Camera.PictureSourceType.CAMERA,
            allowEdit: true,
            encodingType: Camera.EncodingType.JPEG,
            targetWidth: 100,
            targetHeight: 100,
            popoverOptions: CameraPopoverOptions,
            saveToPhotoAlbum: false,
      	  correctOrientation:true
          };
      
          $cordovaCamera.getPicture(options).then(function(imageData) {
            var image = document.getElementById('myImage');
            image.src = "data:image/jpeg;base64," + imageData;
          }, function(err) {
            // error
          });
      
        }, false);
      });

ionic plugin network connection Check

ขั้นตอนการติดตั้ง plugin network information

  1. ติดตั้ง ปลั๊กอิน
    $ ionic plugin add --save cordova-plugin-network-information
  2. เพื่มฟังก์ชั่นใน .run
    var myApp = angular.module(‘myapp’, [‘ionic’])
        .run(function($ionicPlatform, $ionicPopup) {
            $ionicPlatform.ready(function() {
                if(window.Connection) {
                    if(navigator.connection.type == Connection.NONE) {
                        $ionicPopup.confirm({
                            title: “Internet Disconnected”,
                            content: “The internet is disconnected on your device.”
                        })
                        .then(function(result) {
                            if(!result) {
                                ionic.Platform.exitApp();
                            }
                        });
                    }
                }
            });
        });
  3. ทำการทดสอบการทำงาน

แหล่งที่มา คลิ๊ก

angular JS กับการลิงค์ผ่าน URLs กับ IonicFramwork

  1. ติดตั้ง Plugin
    $ cordova plugin add https://gitwipus.apache.org/repos/asf/cordovaplugininappbrowser.git
  2. จากนั้นเขียนโค๊ดดังนี้
    <ion-view title=“Test Page”>
        <ion-content>
            <div class=“list”>
                <a class=“item” href=“#” onclick=“window.open(‘http://www.rmutsv.ac.th/contact’, ‘_system’, ‘location=yes’); return false;”>
                    Open a Browser
                </a>
            </div>
        </ion-content>
    </ion-view>

    หมายเหตุ

    Code Description
    window.open(‘http://example.com’, ‘_system’); Loads in the system browser
    window.open(‘http://example.com’, ‘_blank’); Loads in the InAppBrowser
    window.open(‘http://example.com’, ‘_blank’, ‘location=no’); Loads in the InAppBrowser with no location bar
    window.open(‘http://example.com’, ‘_self’); Loads in the Cordova web view