search add works again
authorcavaliet
Mon, 06 Oct 2014 23:14:08 +0200
changeset 9 962604899225
parent 8 824c87a9084c
child 10 75189d83f849
search add works again
client/app/slideshow/slideshow_controller.js
--- a/client/app/slideshow/slideshow_controller.js	Mon Oct 06 22:52:30 2014 +0200
+++ b/client/app/slideshow/slideshow_controller.js	Mon Oct 06 23:14:08 2014 +0200
@@ -9,17 +9,9 @@
           controller: 'slideshowCtrl'
         });
     })
-    /*.service('slideshowApi', function($resource, context) {
-      console.log('slideshow 5',this);
-      this.slideshow = $resource(context.urls.slideshowUrl);
-    })*/
     .service('slideshowModel', function(searchApi) {
       console.log('slideshow 6',this);
-      /*this.slideshow = function(myVarForData){
-          searchApi.searchResource({q:'stop_email=toto@gmail.com', of: 'json', synthesis: 'false', nresults:'50', callback: 'JSON_CALLBACK'}, myVarForData);
-      };*/
       this.slideshow = searchApi.searchResource({q:'stop_email=toto@gmail.com', of: 'json', synthesis: 'false', nresults:'50', callback: 'JSON_CALLBACK'}).getJsonp();
-      console.log('slideshow 6-2',this);
     })
     .controller('slideshowCtrl', function($scope, $filter, $location, $routeParams, $timeout, searchApi, slideshowModel){
       //console.log('slideshow 7', $location, $routeParams, searchApi);
@@ -32,15 +24,12 @@
           var a = $routeParams.searched.split(',');
           var q = a[0], i = parseInt(a[1]);
           if(a.length===2 && !isNaN(i)){
-              searchApi.searchResource({q:q, of: 'json', synthesis: 'false', nresults:'50', callback: 'JSON_CALLBACK'}).$promise.then(
+              searchApi.searchResource({q:q, of: 'json', synthesis: 'false', nresults:'50', callback: 'JSON_CALLBACK'}).getJsonp().$promise.then(
                   //success
                   function( data ){
-                      var hit = data.hits[i];
-                      $scope.slideshow.images.push({url: $filter('meta')(hit.metas, 'url'), 
-                                                    title: $filter('meta')(hit.metas, 'name'), 
-                                                    description: $filter('meta')(hit.metas, 'description'), tags: [], user_title:'', user_description:''});
+                      $scope.slideshow.hits.push(data.hits[i]);
                       // timeout because
-                      $timeout(function(){$scope.slideshow.images[$scope.slideshow.images.length-1].active = true;}, 200);
+                      $timeout(function(){$scope.slideshow.hits[$scope.slideshow.hits.length-1].active = true;}, 500);
                   },
                   //error
                   function( error ){