خرید بک لینک

Vote count: 0

I have defined a factory in AngularJS similar to the following:

angular.module("myApp").factory(function (){

  var userObject = {
      userID: '',
      email: '',
   };

   userObject.isLoggedIn = function(){
      if(userObject.email === '')
          retu false;
      else
          retu true;
    };

    //more code goes here for the factory
    //...

    retu userObject;
}

The problem is, every time I call the isLoggedIn() function from my controllers, it retus a false. I tried if (this.userObject.email === ''), which retus the error TypeError: Caot read property 'token' of undefined in the console.

This functionality works fine when I define userObject in a service. Is there some scope limitation that I'm missing? What am I doing wrong?

asked 36 secs ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 16 خرداد 1395 ساعت: 5:09

صفحه بندی