restangular
restangular copied to clipboard
Restangular.service, then Restangular.setBaseUrl
Hello,
I don't know if this is a bug or a bad use of Restangular from me.
I have a Restangular service inside angular factory. To simplify, let's say factory is like this (I have some more functions on Factory but not important here)
function powerNodeFactory (Restangular) {
return Restangular.service('<somePath>');
}
module.factory('powerNodeModel', ['Restangular', powerNodeFactory]);
Then I can do followings with my factory
powerNodeModel.getList();
powerNodeModel.one(<someID>);
My problem is : After this factory has been instanciated, I want to change Restangular base URL (from user's choice). So I tried somewhere
Restangular.setBaseUrl('<someDifferentPath>');
But when using the Factory again, it is still using the first Path.
If I try to change base url before using Factory once, it is using the new path as intended.
I guess it's because Factory has been instanciated with this path on the first place and Restangular does not calculate url again after that.
Is it working as intended ? Then should I just forget to use service and Factory if I want to be able to change baseUrl at anytime from anywhere ?
Thank you for your help.
powerNodeFactory.setBaseUrl()?