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.