AngularJS Factory Parameter

后端 未结 3 2002
青春惊慌失措
青春惊慌失措 2020-12-14 18:47

I\'m trying to send a parameter to an angularjs service. Here is my service code :

angular.module(\'skyBiometryServices\', [\'ngResource\'])
.factory(\'Faced         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-14 19:10

    With more research i found a solution :

    factory('Facedetect', function( $resource ) {
        return $resource('skyBiometry/facedetect', {}, {
            query: {
                method : 'GET',
                params : {imageUrl: "http://cdn1-public.ladmedia.fr/var/public/storage/images/dossiers/presidentielles-2012/les-news-sur-les-presidentielles-2012/exclu-public-cauet-pour-ces-presidentielles-personne-ne-me-fait-rever-209063/2064021-1-fre-FR/Exclu-Public-Cauet-Pour-ces-presidentielles-personne-ne-me-fait-rever-!_portrait_w674.jpg"},
                isArray: false
            }
        })
    });
    
    
    function IndexCtrl( $scope, $routeParams, Facedetect ) {
        $scope.imageurl = 'http://flepi.net/images/personne-tendue.jpg';
        $scope.text = $scope.text = Facedetect.get({imageUrl: $scope.imageurl});
    }
    

    I don't know if it's the best way but it works.

提交回复
热议问题