• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

使用AngularJS 应用访问 Android 手机的图片库

angularjs 搞代码 4年前 (2021-12-31) 32次浏览 已收录 0个评论

这篇文章主要介绍了使用AngularJS 应用访问 Android 手机的图片库的相关资料,需要的朋友可以参考下

Download angularjs.zip – 4.5 KB

介绍

这篇文章来说明如何使用AngularJs调用android Apps暴露的REST APIS来访问图像库.

背景

Android和IOS 有很多远程访问的app,但是开发者缺少远程访问手机特征的API.因此,myMoKit的开发是用来填补软件解决方案的缺陷的.

使用代码

使用代码是很简单的,你只要通过web URL 引用myMoKit 服务,你就可以看见所有暴露的REST API了

这些在手机里面的API列表和流媒体.通过AngularJs来调用REST APIS可以很方便的使用$resource 服务。

你可以创建你需要的返回媒体列表的资源

 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; } ]);

利用创建过的模块,你可以很轻易的获取到所有的图片和视频

 var getAllImages = functi<a style="color:transparent">来源gao($daima.com搞@代@#码网</a>on(){ 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; }); };

你可以很方便的通过web 浏览器来展示获取到的一系列图片

 <div class="alert alert-info"> <h4 class="alert-heading">Usage - <i>Image Gallery</i></h4><ul class="row"> <li class="col-lg-2 col-md-2 col-sm-3 col-xs-4" style="margin-bottom:25px"></li></ul></div>

以上所述就是本文的全部内容了,希望大家能够喜欢。

以上就是使用AngularJS 应用访问 Android 手机的图片库的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:使用AngularJS 应用访问 Android 手机的图片库

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址