It is possible? Maybe I'm just approaching the problem on the wrong way.
My code right now:
services.js
angular.module('animestickrServicesUser', ['ngResource']).
factory('User', function ($resource) {
return $resource('jsoncallUser.php', {}, {
query: { method: 'GET', params: { user: userName }, isArray: false },
});
});
controllers.js
function userList($scope, $routeParams, User) {
$scope.userName = $routeParams.userName;
$scope.user = User.query();
}
app.js
angular.module('animestickr', ['animestickrServices','animestickrServicesUser']).
config(['$routeProvider', function ($routeProvider) {
$routeProvider.
when('/main', { templateUrl: 'partials/main.html', controller: animestickrMain }).
when('/anime/:animeTitle', { templateUrl: 'partials/anime.html', controller: animeDetail }).
when('/user/:userName', { templateUrl: 'partials/user.html', controller: userList }).
otherwise({ redirectTo: '/main' });
}]);
As you can see on my service.js I'm trying to use the route :userName from app.js as a value for params (the code is not working right now). Changing services.js to make it works:
angular.module('animestickrServicesUser', ['ngResource']).
factory('User', function ($resource) {
return $resource('jsoncallUser.php', {}, {
query: { method: 'GET', params: { user: 'Powerz' }, isArray: false },
});
});
or
angular.module('animestickrServicesUser', ['ngResource']).
factory('User', function ($resource) {
return $resource('jsoncallUser.php?user=Powerz', {}, {
query: { method: 'GET', isArray: false },
});
});
Those two search for the user "Powerz", but I want that the app use the route (..#/user/Powerz) to search for it.
So... how can the correct route be used as the parametre value?
PD: Sorry for my ugly code :P