Angularjs - Cannot Create Property Method On String
I am sending a normal get request as follows which was working normally: service.show = function (slug) { console.log(slug) return $http.get('api/packages/'
Solution 1:
The second parameter $http.get
expects, is an object with http request configuration.
Have a look at angular documentation. See the Shortcut methods section.
$http.get('/someUrl', config).then(successCallback, errorCallback);
Or better and readable call looks like below:
$http({
method: 'GET',
url: 'api/packages/'+slug
}).then(function(response){
service.package = response.package;
}, functionerrorCallback(response) {
// called asynchronously if an error occurs
// or server returns response with an errorstatus.
});
Post a Comment for "Angularjs - Cannot Create Property Method On String"