angularjs - angular factory - how do i evaulate function and get property value -
i have following code in angular service.
var tstobject = { isallow: false, }; var getdata = function () { var tstdata = tstservice.get(_mydata); if (tstdata != null) return tstdata else return tstobject; } factory.auth = getdata();
i trying isallow
property in controller following
if (!myservice.auth().isallow) { }
it complains auth()
not function. how can property value?
when initialising auth
executing getdata
function. mean factory.auth
contain result, in case object, not function.
so, fix that, should doing is:
factory.auth = getdata;
, auth
refer getdata function.
Comments
Post a Comment