I don\'t know if this is even one of the Angular concepts or possible to do but i have a service that call the user information (name, id, age, ...):
.factory(\'
//Assume Value1 and Service1 have been correctly injected
if (Value1.data === null) {
Your_Var = Service1.call;
} else {
Your_Var = Value1.data;
}
For simplicity sake I would put that in a ternary expression when implementing.
For DRY compliance.
Going with DRY we need a SharedFactoryFuncion to handle $http requests
Your_Var = Service1.call;
//Inside Service1.call
return Value1.data === undefined ? SharedFactoryFuncion.get("url") : Value1.data;
There are numerous ways to handle the return of data from .get() so I won't go there as it's not pertinent.