Hi Ben,
You could also dynamically add the 'zip' parameter and value to the
resource params arguments like so:
var dataService = $resource('
http://search.ams.usda.gov/farmersmarkets/v1/data.svc/zipSearch<http://search.ams.usda.gov/farmersmarkets/v1/data.svc/zipSearch?zip=:zip>',
{callback: 'JSON_CALLBACK'}, {get: {method: 'JSONP'}});
$scope.domainData = dataService.get({zip: '60613'});
Because the ':zip' is not defined in the url angular will automatically
convert it into a query parameter.
Christiaan
On Saturday, August 31, 2013 6:46:22 PM UTC+2, Ben McFerren wrote:
>
> I was experiencing the same error as a result of this bit of code:
>
> var dataService = $resource('
> http://search.ams.usda.gov/farmersmarkets/v1/data.svc/zipSearch?zip=:zip',
> {callback: 'JSON_CALLBACK'}, {get: {method: 'JSONP'}});
> $scope.domainData = dataService.get({zip: '60613'});
>
> It was producing this url:
>
>
> http://search.ams.usda.gov/farmersmarkets/v1/data.svc/zipSearch?zip=60613?callback=angular.callbacks._0<http://search.ams.usda.gov/farmersmarkets/v1/data.svc/zipSearch?zip=60613&callback=angular.callbacks._0>
>
> when I needed this url
>
>
> http://search.ams.usda.gov/farmersmarkets/v1/data.svc/zipSearch?zip=60613&callback=angular.callbacks._0
>
> The & instead of the ? made a difference when the code executed the
> request.
>
> It turned out that I needed to upgrade my js files for angular and
> resource to the latest versions with these commands:
>
> bower install -save angular
> bower install -save angular-resource
>
> The original yo angular command doesn't bring down the most recent version
> of these files so the update was required in order to make this JSONP work
> correctly for me.
>
> After the upgrade, the character was changed in my url string and it was
> able to make the request. The next challenge I have on my list is to
> investigate requirejs to see if i can automate this process upon build.
>
> I wanted to post here so that anyone who may be having similar issues can
> possibly find a solution.
>
> Thanx Mishko for creating this framework. I have enjoyed learning it so
> far and feel that you have done an excellent job explaining its intricacies.
>
> -Ben
>
> @mcferren
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.