Use AngularJS to access the image library _ AngularJS of the Android mobile phone

Source: Internet
Author: User
This article describes how to use AngularJS to access the image library of Android mobile phones. For more information, see Download angularjs.zip-4.5 KB.

Introduction

This article explains how to use AngularJs to call the rest apis exposed by android Apps to access the image library.

Background

Android and IOS have a lot of apps for remote access, but developers lack APIs for remote access to mobile phone features. Therefore, myMoKit is developed to fill in the defects of software solutions.

Use Code

The code is very simple. You only need to reference the myMoKit service through the web URL, you can see all the exposed REST APIs.

These APIS and streaming media in the mobile phone. Calling rest apis through AngularJs makes it easy to use the $ resource Service.

You can create resources that you need to return to the media list.

angular.module('resources.media', [ 'ngResource' ]);angular.module('resources.media').factory(  'Media',  [    '$rootScope',    '$resource',    '$location',    '$http',    function($rootScope, $resource, $location, $http) {     var mediaServices = {};              mediaServices.getAllMedia = function(media) {              var path = $rootScope.host + '/services/api/media/' + media;       return $resource(path, {},         {          get : {           method : 'GET',           isArray : false          }         });     };     return mediaServices;   } ]);

Using the created modules, you can easily obtain all images and videos.

var getAllImages = function(){   Media.getAllMedia('image').get().$promise.then(     function success(resp, headers) {            $scope.allImages = resp;      $scope.images = $scope.allImages.images;      }, function err(httpResponse) {      $scope.errorMsg = httpResponse.status;     });  };      var getAllVideos = function(){   Media.getAllMedia('video').get().$promise.then(     function success(resp, headers) {            $scope.allVideos = resp;      $scope.videos = $scope.allVideos.videos;      }, function err(httpResponse) {      $scope.errorMsg = httpResponse.status;     });  };


You can easily use a web browser to display a series of obtained images.

Usage - Image Gallery

The above is all the content of this article. I hope you will like it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.