How to change the search criteria in a call $ angular JS $

1

I have a JSON link where I have to do searches:

http://www.liverpool.com.mx/tienda?s=xbox&d3106047a194921c01969dfdec083925=json

but I need to change the search criteria, for example to search xbox or something else would change this:

www.liverpool.com.mx/tienda?s=[criterio]& d3106047a194921c01969dfdec083925=json
                              ^^^^^^^^^^

This is the code I have:

angular.module("liverpoolapp",["ngStorage"])
.controller("primerControlador",function($scope,$http,$localStorage) {
    $scope.posts = [];
    $http.get("http://www.liverpool.com.mx/tienda?s=xbox&d3106047a194921c01969dfdec083925=json")
    .success(function(data){
         console.log(data);
         $scope.posts = data;
     })
    .error(function(err){

    });

    $scope.grabar = function(){
        $localStorage.busqueda = $scope.busqueda;
    }
});
    
asked by Daniel Murillo 18.09.2016 в 22:09
source

1 answer

1

You must change the string search

angular.module("liverpoolapp",["ngStorage"])
    .controller("primerControlador",function($scope,$http,$localStorage){
        $scope.posts = [];

        var palabra_a_buscar = "producto";
        var url_busqueda = "http://www.liverpool.com.mx/tienda?s=" + palabra_a_buscar + "&d3106047a194921c01969dfdec083925=json";

        $http.get(url_busqueda)
            .success(function(data){
                console.log(data);
                $scope.posts = data;
        })
        .error(function(err){

        });

        $scope.grabar = function(){
        $localStorage.busqueda = $scope.busqueda;
    }
});
    
answered by 18.09.2016 в 23:26