5 Tips for Using Parse with AngularJS

I’m currently working a brand new project called Slidebean, which I’m a co-founder of. Slidebean lets you create stunning presentations in seconds. Check it out, it’s free! For Slidebean we decided to use two of the hottest app frameworks and components out there: AngularJS as our javascript MVC framework, and Parse as our back-end and cloud storage solution. If you haven’t heard about them, I highly encourage you to do so now, as they’re becoming more and more popular every day. There are few kinks here and there when it comes to using Parse with AngularJS. These are few tips I’ve discovered along the way to iron them out. Hope it saves you some time.

1. Define getters and setters for each of your Parse class fields

Parse lets you get and set custom fields in your classes using – you guessed it – the get and set methods. On Slidebean, users create Presentations, which have a title property. So let’s say we have a presentation variable in a controller’s $scope, and we want to display its title. We would do something like this on our html view:

<div>{{ presentation.get("title") }}</div>

AngularJS, however, uses plain javascript object properties to read and update the values. So if we wanted to update the presentation title using an input field, the ng-model directive is not compatible:


<input type="text" ng-model="presentation.set('title')">
<!-- This doesn't make sense, but just for the sake of the example: -->

One approach I read about here, is to forget about using the Parse Javascript SDK and rely on their REST API to handle models. But there’s another much simpler solution, and that is to define javascript getters and setters for each of your Parse classes. So using AngularJS, we use factory to define a model class called Presentation. The trick is that, inside, we also define a getter and setter per property. In this example, we only have one called title:


angular.module('SlidebeanModels').
  factory('Presentation', function() {

    var Presentation = Parse.Object.extend("Presentation", {
      // Instance methods
    }, {
      // Class methods
    }
    });

    // Title property
    Object.defineProperty(Presentation.prototype, "title", {
      get: function() {
        return this.get("title");
      },
      set: function(aValue) {
        this.set("title", aValue);
      }
    });

    return Presentation;
  });

Now, we have a model class that works seamlessly with ng-model. And so, to update the presentation title, we just do this:


<input type="text" ng-model="presentation.title">

Pretty neat!

UPDATE

As noted by Leo Pelekh in the comments (thanks Leo!), if you wish to add a getter for a property that contains another Parse Object so that it returns your registered class, you can. You just need to make sure you have included the other class as a dependency.

Say you have a Comment class and a Post class, and the Comment has a property called “parentPost”, which is a pointer to the Post the Comment belongs to. If you add a getter to Comment for “parentPost” without including the class Post as a dependency of Comment, then the getter would return a plain Parse.Object instance. On the other hand, if you had included Post as a dependency, the getter will return a instance of Post.

This trick is similar to what’s mentioned in point #3 about the custom User class.

2. Store your current Parse user in the $rootScope

I’ve read that you should almost never set variables in your AngularJS app $rootScope. Parse provides the very convenient Parse.User.current() method, which returns the current active session user. Thing is, changes made to this user variable happen outside of the AngularJS world, and therefore are hard to keep track of and be digested by Angular. I find it convenient, then, to store the current Parse user in a $rootScope variable called sessionUser (or whatever you wish to call it), thus making it accessible to every controller $scope. This var is initialized right after the AngularJS app starts running:


angular.module('SlidebeanApp')
  .config(function ($routeProvider, $locationProvider) {
    // Config goes here
  })
  .run(function($rootScope) {

    Parse.initialize("parse app", "parse credentials");

    $rootScope.sessionUser = Parse.User.current();

  });

To keep things in order, we created a singleton called SessionService, and we made it so that this is the only place where $rootScope.sessionUser is manipulated. This service handles log-ins and log-outs, and updates the variable accordingly. For example, a navigation bar controller that displays the current user can just react to this var, and modify its looks and functionality accordingly:


<!-- Show Log In and Sign Up buttons when there's no session -->
<ul ng-show="sessionUser == null">
  <li><button type="button" ng-click="logIn()">Log In</button></li>
  <li><button type="button" ng-click="signUp()">Sign Up</button></li>
</ul>

<!-- Display the current user when there's a session -->
<ul ng-show="sessionUser != null">
  <li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
      {{ sessionUser.name }}
      <b class="caret"></b>
    </a>
    <ul class="dropdown-menu">
      <li><a ng-href="/profile">Profile</a></li>
      <li><a ng-href="#" ng-click="signOut()">Sign Out</a></li>
    </ul>
  </li>
</ul>

3. Extend Parse.User and include it from the get-go

I found the documentation for extending Parse.User not clear. But basically, if you want to extend the base Parse.User class, it’s just as easy as extending any other Parse.Object. The caveat is: make sure you include your custom class before calling Parse.User.current(), so that you receive an instance of your class. In Slidebean, we wanted to have a custom getImage function for users, where we could abstract away the complexity of retrieving the user’s avatar either from Facebook or from Gravatar. So we extended Parse.User like this:


angular.module('SlidebeanModels').
  factory('SlidebeanUser', function() {

    var User = Parse.User.extend({

      getImage : function() {
        // return the appropriate facebook image url or gravatar image url
      }

    }, {
      // Class methods
    });

    return User;
  });

Then, we just made sure to include our SlidebeanUser class as a dependency for the app’s run method:


.run(function($rootScope, $location, SlidebeanUser) {
  Parse.initialize("parse app", "parse credentials");

  // This is now an instance of our SlidebeanUser class 🙂
  $rootScope.sessionUser = SlidebeanUser.current();

  // and this would work (if there's a user signed in, of course):
  var imageUrl = $rootScope.sessionUser.getImage();
})

4. Delay the Facebook SDK initialization until your AngularJS app has begun running

If you allow users to sign in using Facebook to your app, it’s a good idea to load Facebook SDK until after you have initialized Parse. And it’s a good idea to initialize Parse after your AngularJS app begins running. In general, then, it’s a good idea to have all your application initialization code in one place, and a good place to do that is in your AngularJS app’s run method. In our Slidebean app (and I’d suspect in most apps), the initialization order goes like this:

  1. AngularJS
  2. Parse
  3. Facebook

and to achieve this, our app run method looks like this. Notice how the Facebook SDK async load is placed in here, instead of placed somewhere in the HTML body where it’s normally suggested to.


.run(function($rootScope, $location, SlidebeanUser) {

  // 1) AngularJS app is now running

  // 2) Initialize Parse and set the current user to the $rootScope
  Parse.initialize("parse app", "parse credentials");

  $rootScope.sessionUser = SlidebeanUser.current();

  // 3) Finally, init Facebook
  window.fbAsyncInit = function() {
    Parse.FacebookUtils.init({
      appId: 'facebook app id',
      channelUrl : '//www.slidebean.com/fbchannel.html',
      status: true,
      cookie: true,
      xfbml: true
    });
  };
  (function(d, s, id){
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) {return;}
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_US/all.js";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));
});

Don’t forget to add this in your index.html though, which the Facebook SDK needs:


<div id="fb-root"></div>

5. Wrap Parse async calls inside $q promises

You’ll find that it’s a good idea to wrap Parse asynchronous calls inside AngularJS promises, instead of just performing Parse queries directly in your models or controllers. One of the benefits is that your data changes will be digested by AngularJS automatically. Let’s say on Slidebean we wanted to retrieve all the presentations belonging to the current user. We first defined the Presentation model class and added a static method to retrieve presentations by a given owner. Inside this method, we wrap the async query using AngularJS’ $q promises:


angular.module('SlidebeanModels').
  factory('Presentation', function($q) {

    var Presentation = Parse.Object.extend("Presentation", {
      // Instance methods
    }, {
      // Class methods

      listByUser : function(aUser) {
        var defer = $q.defer();

        var query = new Parse.Query(this);
        query.equalTo("owner", aUser);
        query.find({
          success : function(aPresentations) {
            defer.resolve(aPresentations);
          },
          error : function(aError) {
            defer.reject(aError);
          }
        });

        return defer.promise;
      }
    });

    // Properties
    Object.defineProperty(Presentation.prototype, "owner", {
      get: function() {
        return this.get("owner");
      },
      set: function(aValue) {
        this.set("owner", aValue);
      }
    });
    Object.defineProperty(Presentation.prototype, "title", {
      get: function() {
        return this.get("title");
      },
      set: function(aValue) {
        this.set("title", aValue);
      }
    });

 return Presentation;
 });

Then, inside of any given controller, if we want to fetch the presentations, we would do something like this:


angular.module('SlidebeanApp')
  .controller('DashboardCtrl', function($scope, Presentation) {

    Presentation.listByUser($scope.sessionUser).then(function(aPresentations) {
      $scope.presentations = aPresentations;
    }, function(aError) {
      // Something went wrong, handle the error
    });
  });

And that’s it. Now the list of presentations can be displayed in HTML using ng-repeat. ===== That’s a wrap, for now. If you have any more tips, by all means post them in the comments and I’ll keep adding them in the post. Feel free to post any questions too. Happy coding ^___^

Advertisements

43 thoughts on “5 Tips for Using Parse with AngularJS

    • Hey Felipe. You’re right. I actually later changed the getter and setter definition to this, which is supported by all major browers:

      Object.defineProperty(Presentation.prototype, “title”, {
      get: function() { … },
      set: function(aValue) { … }
      });

      I’ll go ahead and update the post. Thanks!

  1. Some good ideas but I’m a bit confused by 1. How is presentation object related to Presentation Angular service? Is using setters and getters actually the Angular way? I usually simply export Parse objects with .toJSON() into plain JS objects as Angular likes. If then accidental overwriting is a concern, the object can be encapsulated into Angular service with suitable interface to separate reading and writing, which can go beyond the standard get and set.

    • The main advantage of adding the getters and setters to the Presentation object is that you don’t lose the Parse.Object prototype inheritance, and therefore you still have access to all of the Parse.Object methods such as save().

      That being said, I guess you could also convert the Parse objects to simple objects using .toJSON(), but you would have to convert them to Parse.Object instances again to use its methods.

  2. Nikhil says:

    Hello everyone, I am learning how angularjs framework works with Parse.
    Can you give more information how to save the form data in Parse clouding, it would be really helpful.
    Thank you.

  3. Hi Nikhil! As you long as you have an instance of Parse.Object, it’s just a matter of calling .save() on that instance.

    Say you have a form with two inputs, name and email, set to $scope.name and $scope.email, respectively. When the form is submitted, you could create a new Parse.Object like so:

    var Person = Parse.Object.extend(“Person”);
    var person = new Person();
    person.set(“name”, $scope.name);
    person.set(“email”, $scope.email);
    person.save();

    However, you would want to use angular’s factory method to define the Person object there, instead of defining it every time you need it.

    • Nikhil says:

      Thank you Jose for you reply.
      This is my index html file:

      Example

      Name:
      User:

      This is JS file:
      Parse.initialize(“PfF63Z7XdWtctidrATGigEFQsHh6aui6V68BmWSU”, “GIpF3DJGBfprXAml5GLMPhCuldAnyXDLNY41M7zV”);

      angular.module(‘AuthApp’, []).controller(‘Ctrl’, [‘$scope’,function ($scope) {
      var Person=Person.object.extend(“Person”);
      var person= new Person();
      $scope.signUp = function() {

      person.set(“Name”,$scope.name);
      person.set(“email”,$scope.username);
      person.save();

      }

      }]);
      I tried to do the same thing which you told me but i am not sure why its not working now.

  4. Hi everyone.

    I used and alternative to the getters and setters solution, mostly because during the development I ended up with a lot of code in my AngularJS DataService that I constantly had to update in order to match the Parse object structure. What I did was to create two functions in my AngularJS service, one to create a l bindable object from a Parse object that kept an reference to original Parse object and another to recreates Parse object from the bindable object.

    The first one called createBindableObject is called right after loading the data from Parse and returns the plain object used in AngularJS. I also defined a special prefix for the properties stored as JSON in Parse.

    // Creates a AngularJS bindable object from ParseObject
    // with a pointer to original’s ParseObject (bindableObject.parseObject)
    var createBindableObject = function (parseObject) {
    var obj = {};
    var prop;

    for (prop in parseObject.attributes) {
    if (parseObject.attributes.hasOwnProperty(prop) && parseObject.get(prop)) {
    if (prop.indexOf(jsonPrefix) === 0) {
    obj[prop.substring(jsonPrefix.length)] = JSON.parse(parseObject.get(prop));
    }
    else {
    obj[prop] = parseObject.get(prop);
    }
    }
    }

    obj.parseObject = parseObject;

    return obj;
    };

    The second one is the retrieveParseObject, that I use to update Parse object vales and save then back into Parse.

    // Updates properties in ParseObject stored in bindableObject
    // with properties at bindable object
    var retrieveParseObject = function (bindableObject) {
    var parseObject;
    var prop;

    parseObject = bindableObject.parseObject;

    // Sets all properties from bindable object to Parse Object
    for (prop in bindableObject) {
    if (bindableObject.hasOwnProperty(prop) && prop !== ‘parseObject’) {
    if (typeof bindableObject[prop] === ‘object’ &&
    !Parse.File.prototype.isPrototypeOf(bindableObject[prop]) &&
    !Parse.Object.prototype.isPrototypeOf(bindableObject[prop])) {
    // Stringify objects that are not Parse API
    parseObject.set(jsonPrefix + prop, JSON.stringify(bindableObject[prop]));
    }
    else {
    parseObject.set(prop, bindableObject[prop]);
    }
    }
    }

    return parseObject;
    };

    One example on how to load and save data from/to Parse would be:

    var Product = Parse.Object.extend(‘Product’);

    // Loads data from Parse as a bindable object
    // that can be updated from Angular
    getProduct: function (id) {
    var deferred = $q.defer();
    var query = new Parse.Query(Product);

    query.get(id, {
    success: function (results) {
    deferred.resolve(createBindableObject(results));
    },
    error: function (results, error) {
    deferred.reject(error);
    }
    });
    return deferred.promise;
    },

    // Sends data to Parse
    saveProduct: function (bindableObject) {
    var deferred = $q.defer();
    var product = retrieveParseObject(bindableObject);

    product.save({
    success: function (product) {
    deferred.resolve(createBindableObject(product));
    },
    error: function (error) {
    deferred.reject(error);
    }
    });
    return deferred.promise;
    }

    It worked very well for a SPA backend I develop. I hope it can be useful for someone else.

  5. uNki says:

    hi, great post!

    but is the overall benefit of “5. Wrap Parse async calls inside $q promises” ? why not just use standard parse js sdk functions inside my controller?

    best regards!

    • Hey! The reason for me is that when the $q promises are resolved/rejected, Angular performs a scope digestion automatically. This doesn’t happen if you use Parse promises and Parse js sdk functions, so you have to manually call $scope.$apply(). It’s not a big deal though.

      On a similar note, another reason not to use Parse functions directly in the controllers is that I prefer to keep all the Parse related code hidden away inside my Models. This way, if I have to switch Parse with something else, only the model classes have to be modified. It also improves reusability, since any controller can access the models’ functions, which are defined only once.

      Cheers

  6. hey, thanks for these useful tips !

    For the #1, how do you manage deep relations with your model ?

    Supposing you have an author (with a name field) in a presentation, is that possible to write {{presentation.author.name}} by extending a Parse.relations or a Parse.pointer with an author model like you did ?

  7. Yes, that’s how I do it! At least with Parse pointers. Say I have a Comment and Post models. The Comment has a property named “post” which holds a pointer to the Post the Comment belongs to. Comment would have a getter for “post”, which returns an instance of Post. So, as long as you have fetched both, you can do something like {{ comment.post.title }}, assuming Post also has a getter called “title”.

  8. FredyLG says:

    Great article José, just a quick question “out scope”; how would you advice to deal with requests from search engines when using angular and facebook. thanks

  9. Hi Jose. Very useful post — set me on the right path integrating Angular with Parse. Many thanks.

    One challenge with this method that I found is relational objects. Say you have a Post and Comments and you have created getters and setters for both. This works great, until you would like to retrieve Post and it’s Comments, using Parse.Query.include. Post gets the getters and setters, however Comments, being a native Parse object do not — which breaks the paradigm. I have yet to find a good way to get around that. If you have encountered that before, I’d curious to hear how you’ve handled it.

    • Hey Leo,

      I believe as long as you have “included” both Post and Comment before using them (either by having one be a dependency of the other, or by including both of them as dependencies of whoever is consuming them), then it works. On my app, Slidebean, I use Parse’s “include” on queries, and the internal objects are instances of my classes instead of the root Parse.Object class.

      Let me know how it goes!

      • You are right, it does work! This is great as it simplifies things quite a bit. I wonder how does this work exactly — I should check the source one day. Seems like it checks for a JavaScript class with the same name as the ClassName property of the Parse.Object in scope.

        To clarify this for everyone else:

        Say you have a Post parse class and a Comment parse class. You enhance both classes with getters and setters, in PostService and CommentService, as per instructions in this article. If you would like to retrieve a Post with all its Comments you would do something like:

        .service('PostListService', ['PostService', function (Post) {
            
          var query = new Parse.Query(Post);
          query.include('comments');
          return query.find()... 
        

        This will give you an array of Post including your custom getters and setters from PostService. However Post.comments will be an array of plain Parse Objects without custom setters and getters from CommentService. The fix for that is to include that service as a dependency, so the code becomes:

        .service('PostListService', ['PostService','CommentService', function (Post, Comment) {
            
          var query = new Parse.Query(Post);
          query.include('Comments');
          return query.find()... 
        

        Even though Comment argument is not used and your editor may complain, magically comments get their getters and setters, making them Angular friendly

        Jose you may want to add that to your article :).

  10. Hi Jose, first of all congrats for your post, it’s helping me a lot, just one thing, when I try to create the custom method for the User, I always get a error telling that FB is not defined, I think is because the FB library hasn’t initiate yet but I’m almost sure it is. This is the code inside the factory and the rest is exactly the same as you posted and the SessionService that handles the login process, did I miss sth? Thanks a lot in advance:

    var User = Parse.User.extend({

    getImage : function() {

    FB.api(‘/me/picture?width=180&height=180’, function (me) {
    console.log(‘PhotoURL!! ‘ + me.data.url);
    return me.data.url;
    });

    SessionService:

    angular.module(‘devApp’)
    .service(‘SessionService’, [‘$rootScope’, function ($rootScope) {

    this.logIn = function() {

    Parse.FacebookUtils.logIn(’email’, {}).then(function(user) {

    if (!user.existed()) {
    FB.api(‘/me’, function (me) {
    user.set(‘name’, me.first_name);
    user.set(’email’, me.email);
    user.save();

    });

    }

    console.log(‘Logueado!! ‘ + user.get(‘name’));

    $rootScope.sessionUser=user;
    $rootScope.$apply();

      • Hi Jose, I guess I’ve done pretty similar to yours, could be because “ChiquiUser.current();” is been called before Facebook initiates?

        Thanks

        “`css
        .run(function($rootScope, ChiquiUser) {

        //Init Parse
        Parse.initialize(‘ID’, ‘key’);

        $rootScope.sessionUser = ChiquiUser.current();

        //Finally, init Facebook
        window.fbAsyncInit = function() {
        Parse.FacebookUtils.init({
        appId : ‘186829284729789’,
        xfbml : true,
        version : ‘v2.1’
        });
        };

        (function(d, s, id){
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement(s); js.id = id;
        js.src = “//connect.facebook.net/es_ES/sdk.js”;
        fjs.parentNode.insertBefore(js, fjs);
        }(document, ‘script’, ‘facebook-jssdk’));
        “`

    • It’s hard to say without looking at your project completely. Here’s how I setup the FB js sdk in my app’s run method. If you’re getting an error that “FB” is undefined, then it’s definitely related with this.

      // Init Facebook
      window.fbAsyncInit = function() {
      Parse.FacebookUtils.init({
      appId: “the facebook app id”,
      status: true,
      cookie: true,
      xfbml: true
      });
      };
      (function(d, s, id){
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) {return;}
      js = d.createElement(s); js.id = id;
      js.src = “//connect.facebook.net/es_ES/all.js”;
      fjs.parentNode.insertBefore(js, fjs);
      }(document, ‘script’, ‘facebook-jssdk’));

      • I think it caused because I use the same view for login and showing details once logged, I’ll refactor it and create a view just for login and then redirect to te main views.

        Thanks a lot Jose

  11. Hello Jose. You saved my life with this post. In particular the part about wrapping Parse’s async requests with promises. I’m using your awesome method but I’m having issues in including relations. I read the update provided by Leo Pelekh about retrieving related post from comments and it works just fine. But what if I need to retrieve comments from a post?

    The problem is that Comments have a pointer column to Posts, but Posts do not have any column pointing to Comments so calling

    var query = new Parse.Query(Post);
    query.include(‘comments’);

    doesn’t work.
    Could you help me with this?

  12. Hey! Yeah what Leo mentioned was related to parent relationship, e.g. retrieving the parent post of a comment. But if you want to do it the other way around, I would suggest adding a static method to your Comment class that retrieves the list of comments of a post. Then, in your Post class, you can have an instance method that uses the aforementioned Comment static method to retrieve the children comments. Something like this:

        var Presentation = Parse.Object.extend("Presentation", {
          // Instance methods
          fetchComments: function() {
             Comment.listCommentsByPost(this).then(function(comments) {
                // return or store the comments
             });
          }
        }, {
          // Class methods
        }
        });
    
    
        var Comment = Parse.Object.extend("Comment", {
           // Instance methods
        }, {
           // Class methods
           listCommentsByPost: function(post) {
              // Create a Parse.Query to retrieve comments based on the given post
           }
        });
    
  13. Cosmin says:

    Hello Jose,
    I’m new to Angular.js and Parse and I’m trying to build a small application as a learning process. I got used to most of Angular’s directives, and the way to connect DOM elements with pretty much static elements, now I’m moving to the next level, having my data saved and retrieved from Parse.
    Now, I’m trying to get the examples from this page working, so I have a skeleton to build on. I’m stuck on the first one, and don’t know what I’m doing wrong. The code is supposed to read an ExpensesObject from Parse (I have two objects already set, each one contains a field ‘name’ with some value), and display the ‘name’ of the first retrieved object. Again, it’s just a skeleton to build on. Here’s what I have until now:

    js code:
    var app = angular.module(‘expenseTracker’, [ ])
    .factory(‘ExpensesObject’,
    function() {
    var ExpensesObject = Parse.Object.extend(“ExpensesObject”, {
    // Instance methods
    }, {
    // Class methods
    });

    // Title property
    Object.defineProperty(ExpensesObject.prototype, “name”, {
    get: function() {
    return this.get(“name”);
    },
    set: function(aValue) {
    this.set(“name”, aValue);
    }
    });
    return ExpensesObject;
    });

    app.controller(‘ExpenseController’, function($scope, ExpensesObject) {
    loadBooks();
    function loadBooks(){
    Parse.initialize(“…”, “…”);
    // NOT sure if I have to extend here ..
    //var ExpensesObject = Parse.Object.extend(‘ExpensesObject’);
    var query = new Parse.Query(ExpensesObject);
    query.find({
    success: function(results) {
    console.log(“Got ” + results.length + ” elements.”); // i get 2 elements in console
    if (results.length < 1) {
    ExpensesObject.name = 'N/A';
    } else {
    ExpensesObject.name = results[0].attributes.name;
    console.log(results[0].attributes.name); // i get the correct name

    console.log('Expense after loadBooks call:'+ ExpensesObject.name+'<—');
    // i get the empty string
    }
    }
    });

    }; // loadBooks end
    });

    html (styles, script tags and other content removed for simplicity):

    Book name: {{Expense.get(‘name’)}}

    Really hope you have the time to help me with this. Thanks

    • Cosmin says:

      html got messed up, so let me try again, no tags this time

      html ng-app=”expenseTracker”
      body ng-controller=”ExpenseController as expense”
      Book name: {{Expense.get(‘name’)}} // empty string
      input type=”text” ng-model=”Expense.name” // empty input

      • Hey Cosmin,

        I think the problem is that you’re confusing the concepts of class (“ExpensesObject”) and instance (stored in a variable).

        In your example, your Parse Query returns two ExpensesObject instances, stored in “results”. So, if you wanted to grab the first one, you could do something like:

        if (results < 1) {
        $scope.expense = new ExpensesObject();
        $scope.expense.name = "N/A";
        }
        else {
        $scope.expense = results[0];
        }

        And then, in your html, you can bind to $scope.expense like:

        Book name: {{ expense.name }}

        The key is that you have to bind to instances that are stored as variables in your controller’s $scope.

        Hope this helps. Cheers

  14. Cosmin says:

    yes, actually that helps a lot. i didn’t really use scope until now and i was kind of guessing around, and guessing wrong. i started reading more about scopes, and together with your comment, it’s starting to make more sense.

    cheers!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s