欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用AngularJS 應(yīng)用訪問(wèn) Android 手機(jī)的圖片庫(kù)

 更新時(shí)間:2015年03月24日 10:34:50   投稿:hebedich  
這篇文章主要介紹了使用AngularJS 應(yīng)用訪問(wèn) Android 手機(jī)的圖片庫(kù)的相關(guān)資料,需要的朋友可以參考下

Download angularjs.zip - 4.5 KB

介紹

這篇文章來(lái)說(shuō)明如何使用AngularJs調(diào)用android Apps暴露的REST APIS來(lái)訪問(wèn)圖像庫(kù).

背景

Android和IOS 有很多遠(yuǎn)程訪問(wèn)的app,但是開(kāi)發(fā)者缺少遠(yuǎn)程訪問(wèn)手機(jī)特征的API.因此,myMoKit的開(kāi)發(fā)是用來(lái)填補(bǔ)軟件解決方案的缺陷的.

使用代碼

使用代碼是很簡(jiǎn)單的,你只要通過(guò)web URL 引用myMoKit 服務(wù),你就可以看見(jiàn)所有暴露的REST API了

這些在手機(jī)里面的API列表和流媒體.通過(guò)AngularJs來(lái)調(diào)用REST APIS可以很方便的使用$resource 服務(wù)。

你可以創(chuàng)建你需要的返回媒體列表的資源

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

利用創(chuàng)建過(guò)的模塊,你可以很輕易的獲取到所有的圖片和視頻

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


你可以很方便的通過(guò)web 瀏覽器來(lái)展示獲取到的一系列圖片

<div class="alert alert-info">
<p> </p>
 
<h4 class="alert-heading">Usage - <i>Image Gallery</i></h4>
 
<p> </p>
 
 
<ul class="row">
  <li class="col-lg-2 col-md-2 col-sm-3 col-xs-4" ng-repeat="image in images" style="margin-bottom:25px"><img class="img-responsive" ng-click="showImage($index)" ng-src="{{streamImageLink}}?uri={{image.contentUri}}&&id={{image.id}}&kind=1" /></li>
</ul>
</div>

以上所述就是本文的全部?jī)?nèi)容了,希望大家能夠喜歡。

相關(guān)文章

最新評(píng)論