I am trying to retrieve some data from an API using ngResource by utilizing the get
method.
Even though I have set up a factory for my resource, when implementing it in my controller, I encounter an error stating URL.split is not a function
. I'm struggling to identify the issue within my code.
var Myapp = angular.module('starter.controllers', ['ngResource'])
.config(['$resourceProvider', function ($resourceProvider) {
$resourceProvider.defaults.stripTrailingSlashes = false;
}]);
Myapp.factory('Users', function ($resource) {
return $resource('some URL', {}, {
query: {
method: 'GET'
}
});
});
Myapp.controller('DashCtrl', ['$scope', '$state', 'Users', function ($scope, $state, Users) {
Users.query().$promise.then(function (data) {
alert(JSON.stringify(data, null, 4));
}, function (error) {
console.log('Error is: ' + JSON.stringify(error, null, 4));
});
}])