I'm trying to get the list of my users from my firebase collection, but I'm
trying to get this in a resolve (I don't need this data synchronized live).

This is what my resolve looks like:

     app.resolves.UsersList = {
       usersList: ['$firebase', 'firebaseRef', function($firebase,
firebaseRef) {
         return $firebase(firebaseRef.child('users')).$asArray();
       }]
     };


Here's the firebaseRef service just so you know everything that's going on:

     app.factory('firebaseRef', function() {
       return new Firebase('https://#####.firebaseio.com/');
     });


And just to be thorough:

     $stateProvider
         .state('root.users', {
           url: '/users',
           abstract: true,
           views: {
             '': {
               template: '<div ui-view />',
             }
           }
         })
         .state('root.users.list', {
           url: '',
           resolve: app.resolves.UsersList,
           views: {
             '': {
               templateUrl: '/views/usersList.html',
               controller: 'UsersListCtrl'
             }
           }
         })


And the controller:

     app.controller('UsersListCtrl', function ($scope, usersList) {
       $scope.usersList = usersList;
     });


And my jade template:

   ul.users-list
     li(ng-repeat="user in usersList")
       ul.list-inline
         li.userAvatar
           img(ng-src="{{ user.avatar }}")
         li.userDisplayName
           a(ui-sref="root.users.profile({userName: {{user.$id}} })")
{{ user.displayName }}
         li.userEmail
{{ user.email }}


That should cover the relevant parts of the code. First off, please
critique anything and everything, I'm here to learn to do these things the
"right" way.


All users are coming from github authentication (gonna be storing examples
in Gists). I'm currently storing the users at the root of my firebase
collection under the key 'users'. I'm using their username as the key for
each user to make it easy to get a user's profile. Since I was using the
username as the key, I didn't make a 'username' key in each user's profile
(felt like that was duplicating for no reason... but if ANY of this is
funky, or not how you would recommend doing it, please LMK I am open to
change anything and everything).

My current issue is that users.$id doesn't appear to be working for me
(thinking that may not be how I should get the username here). Also, the
point of the resolve was to load the user's list first, then call the
controller and load the template into view. It seems like that is not
happening with the way things are set up.

As I said, in this case, the user's list can be read only, and I'm not
worried about updating them live if a user is added while someone is
looking t the list. So what I want to know is, what's the best way to
accomplish this?


I do have a slight curve ball (second scenario I might as well find out
about)... I'm planning to do a very similar thing to this, but to list all
the examples (will be a collection like the "users", at the root of my
firebase collection)... BUT, this time I will be wanting the examples list
to update live (I won't need to write back to the list from this page.. but
I would like read the "examples" live, in case examples are added while
looking at the list. Because I want this updating live here, I'm guessing
I can just take the code out of what would have been the resolve function,
and user the identical code inside my controller.


Needless to say this app is in very early stages of development, and I
haven't used firebase in like 8 months (and only briefly played around with
it then). I would love for you guys to critique every little thing you
can, and recommend what you would consider the "best/correct" way of doing
the tasks I am currently trying to achieve.


Thanks in advance for the help. I am loving Firebase, just need to get
comfortable with the basics so I can really rock and roll on this project.

Bob

--
You received this message because you are subscribed to the Google Groups "Firebase + AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-angular+unsubscribe@googlegroups.com.
To post to this group, send email to firebase-angular@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-angular/e2954eac-2af2-472a-9010-582ce3fc76a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Michael Wulf at Aug 10, 2014 at 2:26 pm
    You haven't shared your use case here, just the technical details of how
    you plan to implement portions of it, so it will be hard to be specific.

    Generally, if you're bothering with $loaded, you're wasting time and energy
    trying to micromanage things that AngularFire is built to do on its own.
    Just put the array into the scope and let Firebase talk directly to
    Angular's bindings.

    There is generally no need to wait for a list to resolve before rendering
    the page. Angular and Firebase will sort it out. Resolve is best used for
    aspects like ensuring user authentication is processed before loading a
    page to avoid flashing one state and then switching to the other.

    To answer your specific question, the correct answer in resolve is to
    return $loaded (which resolves back to the synchronized array).

    I'm not sure what you mean by wanting the lists to update live. That's
    pretty much the point of AngularFire and most everything happens in
    real-time already.

    On Sat, Aug 9, 2014 at 10:23 PM, Bob Monteverde wrote:

    I'm trying to get the list of my users from my firebase collection, but
    I'm trying to get this in a resolve (I don't need this data synchronized
    live).

    This is what my resolve looks like:

    app.resolves.UsersList = {
    usersList: ['$firebase', 'firebaseRef', function($firebase,
    firebaseRef) {
    return $firebase(firebaseRef.child('users')).$asArray();
    }]
    };


    Here's the firebaseRef service just so you know everything that's going on:

    app.factory('firebaseRef', function() {
    return new Firebase('https://#####.firebaseio.com/');
    });


    And just to be thorough:

    $stateProvider
    .state('root.users', {
    url: '/users',
    abstract: true,
    views: {
    '': {
    template: '<div ui-view />',
    }
    }
    })
    .state('root.users.list', {
    url: '',
    resolve: app.resolves.UsersList,
    views: {
    '': {
    templateUrl: '/views/usersList.html',
    controller: 'UsersListCtrl'
    }
    }
    })


    And the controller:

    app.controller('UsersListCtrl', function ($scope, usersList) {
    $scope.usersList = usersList;
    });


    And my jade template:

    ul.users-list
    li(ng-repeat="user in usersList")
    ul.list-inline
    li.userAvatar
    img(ng-src="{{ user.avatar }}")
    li.userDisplayName
    a(ui-sref="root.users.profile({userName: {{user.$id}} })")
    {{ user.displayName }}
    li.userEmail
    {{ user.email }}


    That should cover the relevant parts of the code. First off, please
    critique anything and everything, I'm here to learn to do these things the
    "right" way.


    All users are coming from github authentication (gonna be storing examples
    in Gists). I'm currently storing the users at the root of my firebase
    collection under the key 'users'. I'm using their username as the key for
    each user to make it easy to get a user's profile. Since I was using the
    username as the key, I didn't make a 'username' key in each user's profile
    (felt like that was duplicating for no reason... but if ANY of this is
    funky, or not how you would recommend doing it, please LMK I am open to
    change anything and everything).

    My current issue is that users.$id doesn't appear to be working for me
    (thinking that may not be how I should get the username here). Also, the
    point of the resolve was to load the user's list first, then call the
    controller and load the template into view. It seems like that is not
    happening with the way things are set up.

    As I said, in this case, the user's list can be read only, and I'm not
    worried about updating them live if a user is added while someone is
    looking t the list. So what I want to know is, what's the best way to
    accomplish this?


    I do have a slight curve ball (second scenario I might as well find out
    about)... I'm planning to do a very similar thing to this, but to list all
    the examples (will be a collection like the "users", at the root of my
    firebase collection)... BUT, this time I will be wanting the examples list
    to update live (I won't need to write back to the list from this page.. but
    I would like read the "examples" live, in case examples are added while
    looking at the list. Because I want this updating live here, I'm guessing
    I can just take the code out of what would have been the resolve function,
    and user the identical code inside my controller.


    Needless to say this app is in very early stages of development, and I
    haven't used firebase in like 8 months (and only briefly played around with
    it then). I would love for you guys to critique every little thing you
    can, and recommend what you would consider the "best/correct" way of doing
    the tasks I am currently trying to achieve.


    Thanks in advance for the help. I am loving Firebase, just need to get
    comfortable with the basics so I can really rock and roll on this project.

    Bob

    --
    You received this message because you are subscribed to the Google Groups
    "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to firebase-angular+unsubscribe@googlegroups.com.
    To post to this group, send email to firebase-angular@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/firebase-angular/e2954eac-2af2-472a-9010-582ce3fc76a8%40googlegroups.com
    <https://groups.google.com/d/msgid/firebase-angular/e2954eac-2af2-472a-9010-582ce3fc76a8%40googlegroups.com?utm_medium=email&utm_source=footer>
    .
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to firebase-angular+unsubscribe@googlegroups.com.
    To post to this group, send email to firebase-angular@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-angular/CAFHX4%3DpuzKy1fwu4jkKLeyPc0fsExqqm15f3KQZAki51rF6h7w%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Bob Monteverde at Aug 10, 2014 at 10:56 pm
    Michael, thank you for the answer. Actually, I was trying to get the
    general answers you gave, so that was wonderful. For the most part I can
    manage to get things to work, but I'm more trying my best to learn the
    "correct" way of doing things. Your answer is exactly the kind of
    information I was hoping for, especially that you touched on the fact of
    WHY the resolve makes complete sense for the authentication data, but is
    not the best way to do things for more general cases like I tried to
    explain.

    The $loaded is good to know (I did manage to get that far after posting
    this last night), and looks like if I did the 2 cases I tried to explain
    differently, I would be wasting my effort.

    Thank you for the info, I will keep moving forwards... hopefully I'm
    getting close to getting the feel for all the basic operations I'll be
    needing to do in this app with regard to Firebase and angularFire. I
    believe I have the authentication side down. I'm still not entirely sure
    if my app's setup is generally how people who are well versed with angular
    would do things. I'm trying to get that info on my other thread that was
    initially about using the Simple Login correctly. I ended up doing a root
    scope with 3 names views at the root (header, main, footer), so I can have
    the currentUser resolve on the header, which also contains my Login/Logout
    functionality (I'm getting the feeling that the Login/Logout code is
    slightly lout of place in the header... maybe people usually have a service
    to encapsulate that code?). Then all the other states are descendants of
    root. My previous idea was having a container that my top level ui-view
    was within, and had a controller on that which everything could inherit
    from it's scope (Couldn't put a resolve on that controller since it didn't
    have a state/url linked to it, so it didn't feel right).

    I'm still not entirely confident that my current or former setups is how a
    pro at angular would do it. But hopefully with a little advice, and some
    small progressions I'll be there. I figure my general goals at least at
    this point align with how lots of others have for their apps. I suppose
    the only real confusion is having a header that's common across all states,
    but needs to know if user is logged in to show the login button or the user
    menu. I'm sure that sounds familiar to most people who have made apps in
    Angular.

    I program on the philosophy, especially when it comes to JavaScript, "Just
    because it works does not mean it's right." Of course more than one way
    may be "right".. I'm just trying my best tot take my time to learn to do
    things in the most commonly accepted manor. So any and all advice that
    leads me towards that goal is very helpful to me.

    Thanks again, hopefully I'll be asking more advanced questions sooner than
    later.

    Bob

    On Sunday, August 10, 2014 10:26:29 AM UTC-4, Michael Kato Wulf wrote:

    You haven't shared your use case here, just the technical details of how
    you plan to implement portions of it, so it will be hard to be specific.

    Generally, if you're bothering with $loaded, you're wasting time and
    energy trying to micromanage things that AngularFire is built to do on its
    own. Just put the array into the scope and let Firebase talk directly to
    Angular's bindings.

    There is generally no need to wait for a list to resolve before rendering
    the page. Angular and Firebase will sort it out. Resolve is best used for
    aspects like ensuring user authentication is processed before loading a
    page to avoid flashing one state and then switching to the other.

    To answer your specific question, the correct answer in resolve is to
    return $loaded (which resolves back to the synchronized array).

    I'm not sure what you mean by wanting the lists to update live. That's
    pretty much the point of AngularFire and most everything happens in
    real-time already.


    On Sat, Aug 9, 2014 at 10:23 PM, Bob Monteverde <bobmon...@gmail.com
    <javascript:>> wrote:
    I'm trying to get the list of my users from my firebase collection, but
    I'm trying to get this in a resolve (I don't need this data synchronized
    live).

    This is what my resolve looks like:

    app.resolves.UsersList = {
    usersList: ['$firebase', 'firebaseRef', function($firebase,
    firebaseRef) {
    return $firebase(firebaseRef.child('users')).$asArray();
    }]
    };


    Here's the firebaseRef service just so you know everything that's going
    on:

    app.factory('firebaseRef', function() {
    return new Firebase('https://#####.firebaseio.com/');
    });


    And just to be thorough:

    $stateProvider
    .state('root.users', {
    url: '/users',
    abstract: true,
    views: {
    '': {
    template: '<div ui-view />',
    }
    }
    })
    .state('root.users.list', {
    url: '',
    resolve: app.resolves.UsersList,
    views: {
    '': {
    templateUrl: '/views/usersList.html',
    controller: 'UsersListCtrl'
    }
    }
    })


    And the controller:

    app.controller('UsersListCtrl', function ($scope, usersList) {
    $scope.usersList = usersList;
    });


    And my jade template:

    ul.users-list
    li(ng-repeat="user in usersList")
    ul.list-inline
    li.userAvatar
    img(ng-src="{{ user.avatar }}")
    li.userDisplayName
    a(ui-sref="root.users.profile({userName: {{user.$id}} })")
    {{ user.displayName }}
    li.userEmail
    {{ user.email }}


    That should cover the relevant parts of the code. First off, please
    critique anything and everything, I'm here to learn to do these things the
    "right" way.


    All users are coming from github authentication (gonna be storing
    examples in Gists). I'm currently storing the users at the root of my
    firebase collection under the key 'users'. I'm using their username as the
    key for each user to make it easy to get a user's profile. Since I was
    using the username as the key, I didn't make a 'username' key in each
    user's profile (felt like that was duplicating for no reason... but if ANY
    of this is funky, or not how you would recommend doing it, please LMK I am
    open to change anything and everything).

    My current issue is that users.$id doesn't appear to be working for me
    (thinking that may not be how I should get the username here). Also, the
    point of the resolve was to load the user's list first, then call the
    controller and load the template into view. It seems like that is not
    happening with the way things are set up.

    As I said, in this case, the user's list can be read only, and I'm not
    worried about updating them live if a user is added while someone is
    looking t the list. So what I want to know is, what's the best way to
    accomplish this?


    I do have a slight curve ball (second scenario I might as well find out
    about)... I'm planning to do a very similar thing to this, but to list all
    the examples (will be a collection like the "users", at the root of my
    firebase collection)... BUT, this time I will be wanting the examples list
    to update live (I won't need to write back to the list from this page.. but
    I would like read the "examples" live, in case examples are added while
    looking at the list. Because I want this updating live here, I'm guessing
    I can just take the code out of what would have been the resolve function,
    and user the identical code inside my controller.


    Needless to say this app is in very early stages of development, and I
    haven't used firebase in like 8 months (and only briefly played around with
    it then). I would love for you guys to critique every little thing you
    can, and recommend what you would consider the "best/correct" way of doing
    the tasks I am currently trying to achieve.


    Thanks in advance for the help. I am loving Firebase, just need to get
    comfortable with the basics so I can really rock and roll on this project.

    Bob

    --
    You received this message because you are subscribed to the Google Groups
    "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to firebase-angul...@googlegroups.com <javascript:>.
    To post to this group, send email to firebase...@googlegroups.com
    <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/firebase-angular/e2954eac-2af2-472a-9010-582ce3fc76a8%40googlegroups.com
    <https://groups.google.com/d/msgid/firebase-angular/e2954eac-2af2-472a-9010-582ce3fc76a8%40googlegroups.com?utm_medium=email&utm_source=footer>
    .
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to firebase-angular+unsubscribe@googlegroups.com.
    To post to this group, send email to firebase-angular@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-angular/d68bc2f7-9f02-4ae5-9ed2-dd10c56e3f51%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Michael Wulf at Aug 11, 2014 at 2:35 pm
    Glad to help. Angular and Firebase are both sophisticated tools. Sometimes
    the best way to figure out the "pro" way to do things is to dive in and
    break stuff for a while. Well, it may not be the best way, but it's how I
    wrap my brain around complex ideas. : )

    If you haven't tried out angularFire-seed
    <https://github.com/firebase/angularfire-seed/>, you may want to tinker a
    bit there as well. It covers some common practices with setting up arrays,
    objects, and auth.

    Cheers,

    On Sun, Aug 10, 2014 at 3:14 PM, Bob Monteverde wrote:

    Michael, thank you for the answer. Actually, I was trying to get the
    general answers you gave, so that was wonderful. For the most part I can
    manage to get things to work, but I'm more trying my best to learn the
    "correct" way of doing things. Your answer is exactly the kind of
    information I was hoping for, especially that you touched on the fact of
    WHY the resolve makes complete sense for the authentication data, but is
    not the best way to do things for more general cases like I tried to
    explain.

    The $loaded is good to know (I did manage to get that far after posting
    this last night), and looks like if I did the 2 cases I tried to explain
    differently, I would be wasting my effort.

    Thank you for the info, I will keep moving forwards... hopefully I'm
    getting close to getting the feel for all the basic operations I'll be
    needing to do in this app with regard to Firebase and angularFire. I
    believe I have the authentication side down. I'm still not entirely sure
    if my app's setup is generally how people who are well versed with angular
    would do things. I'm trying to get that info on my other thread that was
    initially about using the Simple Login correctly. I ended up doing a root
    scope with 3 names views at the root (header, main, footer), so I can have
    the currentUser resolve on the header, which also contains my Login/Logout
    functionality (I'm getting the feeling that the Login/Logout code is
    slightly lout of place in the header... maybe people usually have a service
    to encapsulate that code?). Then all the other states are descendants of
    root. My previous idea was having a container that my top level ui-view
    was within, and had a controller on that which everything could inherit
    from it's scope (Couldn't put a resolve on that controller since it didn't
    have a state/url linked to it, so it didn't feel right).

    I'm still not entirely confident that my current or former setups is how a
    pro at angular would do it. But hopefully with a little advice, and some
    small progressions I'll be there. I figure my general goals at least at
    this point align with how lots of others have for their apps. I suppose
    the only real confusion is having a header that's common across all states,
    but needs to know if user is logged in to show the login button or the user
    menu. I'm sure that sounds familiar to most people who have made apps in
    Angular.

    I program on the philosophy, especially when it comes to JavaScript, "Just
    because it works does not mean it's right." Of course more than one way
    may be "right".. I'm just trying my best tot take my time to learn to do
    things in the most commonly accepted manor. So any and all advice that
    leads me towards that goal is very helpful to me.

    Thanks again, hopefully I'll be asking more advanced questions sooner than
    later.

    Bob

    On Sunday, August 10, 2014 10:26:29 AM UTC-4, Michael Kato Wulf wrote:

    You haven't shared your use case here, just the technical details of how
    you plan to implement portions of it, so it will be hard to be specific.

    Generally, if you're bothering with $loaded, you're wasting time and
    energy trying to micromanage things that AngularFire is built to do on its
    own. Just put the array into the scope and let Firebase talk directly to
    Angular's bindings.

    There is generally no need to wait for a list to resolve before rendering
    the page. Angular and Firebase will sort it out. Resolve is best used for
    aspects like ensuring user authentication is processed before loading a
    page to avoid flashing one state and then switching to the other.

    To answer your specific question, the correct answer in resolve is to
    return $loaded (which resolves back to the synchronized array).

    I'm not sure what you mean by wanting the lists to update live. That's
    pretty much the point of AngularFire and most everything happens in
    real-time already.


    On Sat, Aug 9, 2014 at 10:23 PM, Bob Monteverde <bobmon...@gmail.com>
    wrote:
    I'm trying to get the list of my users from my firebase collection, but
    I'm trying to get this in a resolve (I don't need this data synchronized
    live).

    This is what my resolve looks like:

    app.resolves.UsersList = {
    usersList: ['$firebase', 'firebaseRef', function($firebase,
    firebaseRef) {
    return $firebase(firebaseRef.child('users')).$asArray();
    }]
    };


    Here's the firebaseRef service just so you know everything that's going
    on:

    app.factory('firebaseRef', function() {
    return new Firebase('https://#####.firebaseio.com/');
    });


    And just to be thorough:

    $stateProvider
    .state('root.users', {
    url: '/users',
    abstract: true,
    views: {
    '': {
    template: '<div ui-view />',
    }
    }
    })
    .state('root.users.list', {
    url: '',
    resolve: app.resolves.UsersList,
    views: {
    '': {
    templateUrl: '/views/usersList.html',
    controller: 'UsersListCtrl'
    }
    }
    })


    And the controller:

    app.controller('UsersListCtrl', function ($scope, usersList) {
    $scope.usersList = usersList;
    });


    And my jade template:

    ul.users-list
    li(ng-repeat="user in usersList")
    ul.list-inline
    li.userAvatar
    img(ng-src="{{ user.avatar }}")
    li.userDisplayName
    a(ui-sref="root.users.profile({userName: {{user.$id}} })")
    {{ user.displayName }}
    li.userEmail
    {{ user.email }}


    That should cover the relevant parts of the code. First off, please
    critique anything and everything, I'm here to learn to do these things the
    "right" way.


    All users are coming from github authentication (gonna be storing
    examples in Gists). I'm currently storing the users at the root of my
    firebase collection under the key 'users'. I'm using their username as the
    key for each user to make it easy to get a user's profile. Since I was
    using the username as the key, I didn't make a 'username' key in each
    user's profile (felt like that was duplicating for no reason... but if ANY
    of this is funky, or not how you would recommend doing it, please LMK I am
    open to change anything and everything).

    My current issue is that users.$id doesn't appear to be working for me
    (thinking that may not be how I should get the username here). Also, the
    point of the resolve was to load the user's list first, then call the
    controller and load the template into view. It seems like that is not
    happening with the way things are set up.

    As I said, in this case, the user's list can be read only, and I'm not
    worried about updating them live if a user is added while someone is
    looking t the list. So what I want to know is, what's the best way to
    accomplish this?


    I do have a slight curve ball (second scenario I might as well find out
    about)... I'm planning to do a very similar thing to this, but to list all
    the examples (will be a collection like the "users", at the root of my
    firebase collection)... BUT, this time I will be wanting the examples list
    to update live (I won't need to write back to the list from this page.. but
    I would like read the "examples" live, in case examples are added while
    looking at the list. Because I want this updating live here, I'm guessing
    I can just take the code out of what would have been the resolve function,
    and user the identical code inside my controller.


    Needless to say this app is in very early stages of development, and I
    haven't used firebase in like 8 months (and only briefly played around with
    it then). I would love for you guys to critique every little thing you
    can, and recommend what you would consider the "best/correct" way of doing
    the tasks I am currently trying to achieve.


    Thanks in advance for the help. I am loving Firebase, just need to get
    comfortable with the basics so I can really rock and roll on this project.

    Bob

    --
    You received this message because you are subscribed to the Google
    Groups "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to firebase-angul...@googlegroups.com.
    To post to this group, send email to firebase...@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/
    msgid/firebase-angular/e2954eac-2af2-472a-9010-
    582ce3fc76a8%40googlegroups.com
    <https://groups.google.com/d/msgid/firebase-angular/e2954eac-2af2-472a-9010-582ce3fc76a8%40googlegroups.com?utm_medium=email&utm_source=footer>
    .
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups
    "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to firebase-angular+unsubscribe@googlegroups.com.
    To post to this group, send email to firebase-angular@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/firebase-angular/d68bc2f7-9f02-4ae5-9ed2-dd10c56e3f51%40googlegroups.com
    <https://groups.google.com/d/msgid/firebase-angular/d68bc2f7-9f02-4ae5-9ed2-dd10c56e3f51%40googlegroups.com?utm_medium=email&utm_source=footer>
    .

    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to firebase-angular+unsubscribe@googlegroups.com.
    To post to this group, send email to firebase-angular@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-angular/CAFHX4%3Dpg9rkvYs%2B0n2QFCv958BEYDmuNtigkziPuD64DAcAmYQ%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Bob Monteverde at Aug 11, 2014 at 3:36 pm
    Oh, beautiful. Can't believe I missed the seed app. That will def be
    useful, looks like it covers more than I have already (haven't gotten to
    security rules, figured that could wait till things were close to setup and
    ready to go online). It'll also help for me to convert this to closer to
    what I'm doing... utilizing ui-router, github auth and api, etc. It's
    definitely interesting how different the structure can be by implementing
    just ui-router and utilizing it.

    Thanks,

    Bob


    On Sunday, August 10, 2014 1:23:43 AM UTC-4, Bob Monteverde wrote:

    I'm trying to get the list of my users from my firebase collection, but
    I'm trying to get this in a resolve (I don't need this data synchronized
    live).

    This is what my resolve looks like:

    app.resolves.UsersList = {
    usersList: ['$firebase', 'firebaseRef', function($firebase,
    firebaseRef) {
    return $firebase(firebaseRef.child('users')).$asArray();
    }]
    };


    Here's the firebaseRef service just so you know everything that's going on:

    app.factory('firebaseRef', function() {
    return new Firebase('https://#####.firebaseio.com/');
    });


    And just to be thorough:

    $stateProvider
    .state('root.users', {
    url: '/users',
    abstract: true,
    views: {
    '': {
    template: '<div ui-view />',
    }
    }
    })
    .state('root.users.list', {
    url: '',
    resolve: app.resolves.UsersList,
    views: {
    '': {
    templateUrl: '/views/usersList.html',
    controller: 'UsersListCtrl'
    }
    }
    })


    And the controller:

    app.controller('UsersListCtrl', function ($scope, usersList) {
    $scope.usersList = usersList;
    });


    And my jade template:

    ul.users-list
    li(ng-repeat="user in usersList")
    ul.list-inline
    li.userAvatar
    img(ng-src="{{ user.avatar }}")
    li.userDisplayName
    a(ui-sref="root.users.profile({userName: {{user.$id}} })")
    {{ user.displayName }}
    li.userEmail
    {{ user.email }}


    That should cover the relevant parts of the code. First off, please
    critique anything and everything, I'm here to learn to do these things the
    "right" way.


    All users are coming from github authentication (gonna be storing examples
    in Gists). I'm currently storing the users at the root of my firebase
    collection under the key 'users'. I'm using their username as the key for
    each user to make it easy to get a user's profile. Since I was using the
    username as the key, I didn't make a 'username' key in each user's profile
    (felt like that was duplicating for no reason... but if ANY of this is
    funky, or not how you would recommend doing it, please LMK I am open to
    change anything and everything).

    My current issue is that users.$id doesn't appear to be working for me
    (thinking that may not be how I should get the username here). Also, the
    point of the resolve was to load the user's list first, then call the
    controller and load the template into view. It seems like that is not
    happening with the way things are set up.

    As I said, in this case, the user's list can be read only, and I'm not
    worried about updating them live if a user is added while someone is
    looking t the list. So what I want to know is, what's the best way to
    accomplish this?


    I do have a slight curve ball (second scenario I might as well find out
    about)... I'm planning to do a very similar thing to this, but to list all
    the examples (will be a collection like the "users", at the root of my
    firebase collection)... BUT, this time I will be wanting the examples list
    to update live (I won't need to write back to the list from this page.. but
    I would like read the "examples" live, in case examples are added while
    looking at the list. Because I want this updating live here, I'm guessing
    I can just take the code out of what would have been the resolve function,
    and user the identical code inside my controller.


    Needless to say this app is in very early stages of development, and I
    haven't used firebase in like 8 months (and only briefly played around with
    it then). I would love for you guys to critique every little thing you
    can, and recommend what you would consider the "best/correct" way of doing
    the tasks I am currently trying to achieve.


    Thanks in advance for the help. I am loving Firebase, just need to get
    comfortable with the basics so I can really rock and roll on this project.

    Bob
    --
    You received this message because you are subscribed to the Google Groups "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to firebase-angular+unsubscribe@googlegroups.com.
    To post to this group, send email to firebase-angular@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-angular/1c579223-4208-4e31-b1f1-8361d8c7f286%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Michael Wulf at Aug 11, 2014 at 3:43 pm
    $id should be sufficient, unless you want to do some sorting/searching in
    an ng-repeat and use username as criteria (in which case I'd probably keep
    it in the data for simplicity, although there are plenty of ways around
    this as well for advanced users).

    Glad the seed looks useful! The resolve code should work with either
    ngRoute or ui-router and adapting the redirects is a simple matter of
    changing out $routeProvider for $stateProvider in a few places and making a
    tweak or two.

    Cheers,

    On Mon, Aug 11, 2014 at 8:00 AM, Bob Monteverde wrote:

    Oh, beautiful. Can't believe I missed the seed app. That will def be
    useful, looks like it covers more than I have already (haven't gotten to
    security rules, figured that could wait till things were close to setup and
    ready to go online). It'll also help for me to convert this to closer to
    what I'm doing... utilizing ui-router, github auth and api, etc. It's
    definitely interesting how different the structure can be by implementing
    just ui-router and utilizing it.

    Thanks,

    Bob


    On Sunday, August 10, 2014 1:23:43 AM UTC-4, Bob Monteverde wrote:

    I'm trying to get the list of my users from my firebase collection, but
    I'm trying to get this in a resolve (I don't need this data synchronized
    live).

    This is what my resolve looks like:

    app.resolves.UsersList = {
    usersList: ['$firebase', 'firebaseRef', function($firebase,
    firebaseRef) {
    return $firebase(firebaseRef.child('users')).$asArray();
    }]
    };


    Here's the firebaseRef service just so you know everything that's going
    on:

    app.factory('firebaseRef', function() {
    return new Firebase('https://#####.firebaseio.com/');
    });


    And just to be thorough:

    $stateProvider
    .state('root.users', {
    url: '/users',
    abstract: true,
    views: {
    '': {
    template: '<div ui-view />',
    }
    }
    })
    .state('root.users.list', {
    url: '',
    resolve: app.resolves.UsersList,
    views: {
    '': {
    templateUrl: '/views/usersList.html',
    controller: 'UsersListCtrl'
    }
    }
    })


    And the controller:

    app.controller('UsersListCtrl', function ($scope, usersList) {
    $scope.usersList = usersList;
    });


    And my jade template:

    ul.users-list
    li(ng-repeat="user in usersList")
    ul.list-inline
    li.userAvatar
    img(ng-src="{{ user.avatar }}")
    li.userDisplayName
    a(ui-sref="root.users.profile({userName: {{user.$id}} })")
    {{ user.displayName }}
    li.userEmail
    {{ user.email }}


    That should cover the relevant parts of the code. First off, please
    critique anything and everything, I'm here to learn to do these things the
    "right" way.


    All users are coming from github authentication (gonna be storing
    examples in Gists). I'm currently storing the users at the root of my
    firebase collection under the key 'users'. I'm using their username as the
    key for each user to make it easy to get a user's profile. Since I was
    using the username as the key, I didn't make a 'username' key in each
    user's profile (felt like that was duplicating for no reason... but if ANY
    of this is funky, or not how you would recommend doing it, please LMK I am
    open to change anything and everything).

    My current issue is that users.$id doesn't appear to be working for me
    (thinking that may not be how I should get the username here). Also, the
    point of the resolve was to load the user's list first, then call the
    controller and load the template into view. It seems like that is not
    happening with the way things are set up.

    As I said, in this case, the user's list can be read only, and I'm not
    worried about updating them live if a user is added while someone is
    looking t the list. So what I want to know is, what's the best way to
    accomplish this?


    I do have a slight curve ball (second scenario I might as well find out
    about)... I'm planning to do a very similar thing to this, but to list all
    the examples (will be a collection like the "users", at the root of my
    firebase collection)... BUT, this time I will be wanting the examples list
    to update live (I won't need to write back to the list from this page.. but
    I would like read the "examples" live, in case examples are added while
    looking at the list. Because I want this updating live here, I'm guessing
    I can just take the code out of what would have been the resolve function,
    and user the identical code inside my controller.


    Needless to say this app is in very early stages of development, and I
    haven't used firebase in like 8 months (and only briefly played around with
    it then). I would love for you guys to critique every little thing you
    can, and recommend what you would consider the "best/correct" way of doing
    the tasks I am currently trying to achieve.


    Thanks in advance for the help. I am loving Firebase, just need to get
    comfortable with the basics so I can really rock and roll on this project.

    Bob
    --
    You received this message because you are subscribed to the Google Groups
    "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to firebase-angular+unsubscribe@googlegroups.com.
    To post to this group, send email to firebase-angular@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/firebase-angular/1c579223-4208-4e31-b1f1-8361d8c7f286%40googlegroups.com
    <https://groups.google.com/d/msgid/firebase-angular/1c579223-4208-4e31-b1f1-8361d8c7f286%40googlegroups.com?utm_medium=email&utm_source=footer>
    .

    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to firebase-angular+unsubscribe@googlegroups.com.
    To post to this group, send email to firebase-angular@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-angular/CAFHX4%3Drc4MDT-nncVMO7K_hkSnnwk%2B95n2vz-bcTv_2YTLOqBA%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Bob Monteverde at Aug 11, 2014 at 5:56 pm
    Well, what I mean by switching over to ui-router (didn't get enough to to
    investigate the seed yet, did a once over on the code) isn't just getting
    the routes to work... ngRoute to ui-router can pretty much be a 1 to 1
    conversion... but that wouldn't be super beneficial... gotta usually
    restructure things to make use of multiple named and nested views.

    I will say, I'm not a big fan of separating my code into the modules that
    the seed does (by that I mean 'myApp.services', 'myApp.controllers',
    'myApp.filters'). To me, that doesn't really make sense, I feel a module
    should be more of an encapsulated feature (potentially a combination of
    services, filters, directives, etc.) The only reason I really break my own
    app into separate modules is to have pieces that are reusable in other
    apps, or to isolate complete functional parts.

    With that said, I need to spend some more time looking a things to get a
    feel for how the seed app works. At first I was really confused at why
    firebase.utils is not a module used directly by myApp... but now I guess
    it's because my app splits the different angular components into modules.

    Anyway, I'm gonna try to spend some time tonight getting accustomed to the
    seed code, and will likely be making a new topic with any questions I have
    with the seed's structure or functionality. I do wish it wasn't broken
    down into the modules the way it is, but I will have to deal with that,
    maybe I'll even re-code it to not be broken down like that, and maybe even
    add ui-router and whatever else I always use, so it will be more similar to
    how I would build the seed.

    Thanks again,

    Bob
    On Monday, August 11, 2014 11:43:16 AM UTC-4, Michael Kato Wulf wrote:

    $id should be sufficient, unless you want to do some sorting/searching in
    an ng-repeat and use username as criteria (in which case I'd probably keep
    it in the data for simplicity, although there are plenty of ways around
    this as well for advanced users).

    Glad the seed looks useful! The resolve code should work with either
    ngRoute or ui-router and adapting the redirects is a simple matter of
    changing out $routeProvider for $stateProvider in a few places and making a
    tweak or two.

    Cheers,


    On Mon, Aug 11, 2014 at 8:00 AM, Bob Monteverde <bobmon...@gmail.com
    <javascript:>> wrote:
    Oh, beautiful. Can't believe I missed the seed app. That will def be
    useful, looks like it covers more than I have already (haven't gotten to
    security rules, figured that could wait till things were close to setup and
    ready to go online). It'll also help for me to convert this to closer to
    what I'm doing... utilizing ui-router, github auth and api, etc. It's
    definitely interesting how different the structure can be by implementing
    just ui-router and utilizing it.

    Thanks,

    Bob


    On Sunday, August 10, 2014 1:23:43 AM UTC-4, Bob Monteverde wrote:

    I'm trying to get the list of my users from my firebase collection, but
    I'm trying to get this in a resolve (I don't need this data synchronized
    live).

    This is what my resolve looks like:

    app.resolves.UsersList = {
    usersList: ['$firebase', 'firebaseRef', function($firebase,
    firebaseRef) {
    return $firebase(firebaseRef.child('users')).$asArray();
    }]
    };


    Here's the firebaseRef service just so you know everything that's going
    on:

    app.factory('firebaseRef', function() {
    return new Firebase('https://#####.firebaseio.com/');
    });


    And just to be thorough:

    $stateProvider
    .state('root.users', {
    url: '/users',
    abstract: true,
    views: {
    '': {
    template: '<div ui-view />',
    }
    }
    })
    .state('root.users.list', {
    url: '',
    resolve: app.resolves.UsersList,
    views: {
    '': {
    templateUrl: '/views/usersList.html',
    controller: 'UsersListCtrl'
    }
    }
    })


    And the controller:

    app.controller('UsersListCtrl', function ($scope, usersList) {
    $scope.usersList = usersList;
    });


    And my jade template:

    ul.users-list
    li(ng-repeat="user in usersList")
    ul.list-inline
    li.userAvatar
    img(ng-src="{{ user.avatar }}")
    li.userDisplayName
    a(ui-sref="root.users.profile({userName: {{user.$id}} })")
    {{ user.displayName }}
    li.userEmail
    {{ user.email }}


    That should cover the relevant parts of the code. First off, please
    critique anything and everything, I'm here to learn to do these things the
    "right" way.


    All users are coming from github authentication (gonna be storing
    examples in Gists). I'm currently storing the users at the root of my
    firebase collection under the key 'users'. I'm using their username as the
    key for each user to make it easy to get a user's profile. Since I was
    using the username as the key, I didn't make a 'username' key in each
    user's profile (felt like that was duplicating for no reason... but if ANY
    of this is funky, or not how you would recommend doing it, please LMK I am
    open to change anything and everything).

    My current issue is that users.$id doesn't appear to be working for me
    (thinking that may not be how I should get the username here). Also, the
    point of the resolve was to load the user's list first, then call the
    controller and load the template into view. It seems like that is not
    happening with the way things are set up.

    As I said, in this case, the user's list can be read only, and I'm not
    worried about updating them live if a user is added while someone is
    looking t the list. So what I want to know is, what's the best way to
    accomplish this?


    I do have a slight curve ball (second scenario I might as well find out
    about)... I'm planning to do a very similar thing to this, but to list all
    the examples (will be a collection like the "users", at the root of my
    firebase collection)... BUT, this time I will be wanting the examples list
    to update live (I won't need to write back to the list from this page.. but
    I would like read the "examples" live, in case examples are added while
    looking at the list. Because I want this updating live here, I'm guessing
    I can just take the code out of what would have been the resolve function,
    and user the identical code inside my controller.


    Needless to say this app is in very early stages of development, and I
    haven't used firebase in like 8 months (and only briefly played around with
    it then). I would love for you guys to critique every little thing you
    can, and recommend what you would consider the "best/correct" way of doing
    the tasks I am currently trying to achieve.


    Thanks in advance for the help. I am loving Firebase, just need to get
    comfortable with the basics so I can really rock and roll on this project.

    Bob
    --
    You received this message because you are subscribed to the Google Groups
    "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to firebase-angul...@googlegroups.com <javascript:>.
    To post to this group, send email to firebase...@googlegroups.com
    <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/firebase-angular/1c579223-4208-4e31-b1f1-8361d8c7f286%40googlegroups.com
    <https://groups.google.com/d/msgid/firebase-angular/1c579223-4208-4e31-b1f1-8361d8c7f286%40googlegroups.com?utm_medium=email&utm_source=footer>
    .

    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to firebase-angular+unsubscribe@googlegroups.com.
    To post to this group, send email to firebase-angular@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-angular/2edfb2e3-9416-4c8a-b0dc-7f79e5f0ec31%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Bob Monteverde at Aug 11, 2014 at 3:36 pm
    Oh, I forgot to double check from my initial post. I'm storing my users by
    using the username as key, to make it very easy for me to get their info,
    and have readable urls. I realized I had a stupid type preventing me from
    using user.$id to get that username back. Does it make sense to still have
    a 'username' field within the user object I'm storing, or should I just be
    using $id to get that value?

    Thanks,

    Bob
    On Sunday, August 10, 2014 1:23:43 AM UTC-4, Bob Monteverde wrote:

    I'm trying to get the list of my users from my firebase collection, but
    I'm trying to get this in a resolve (I don't need this data synchronized
    live).

    This is what my resolve looks like:

    app.resolves.UsersList = {
    usersList: ['$firebase', 'firebaseRef', function($firebase,
    firebaseRef) {
    return $firebase(firebaseRef.child('users')).$asArray();
    }]
    };


    Here's the firebaseRef service just so you know everything that's going on:

    app.factory('firebaseRef', function() {
    return new Firebase('https://#####.firebaseio.com/');
    });


    And just to be thorough:

    $stateProvider
    .state('root.users', {
    url: '/users',
    abstract: true,
    views: {
    '': {
    template: '<div ui-view />',
    }
    }
    })
    .state('root.users.list', {
    url: '',
    resolve: app.resolves.UsersList,
    views: {
    '': {
    templateUrl: '/views/usersList.html',
    controller: 'UsersListCtrl'
    }
    }
    })


    And the controller:

    app.controller('UsersListCtrl', function ($scope, usersList) {
    $scope.usersList = usersList;
    });


    And my jade template:

    ul.users-list
    li(ng-repeat="user in usersList")
    ul.list-inline
    li.userAvatar
    img(ng-src="{{ user.avatar }}")
    li.userDisplayName
    a(ui-sref="root.users.profile({userName: {{user.$id}} })")
    {{ user.displayName }}
    li.userEmail
    {{ user.email }}


    That should cover the relevant parts of the code. First off, please
    critique anything and everything, I'm here to learn to do these things the
    "right" way.


    All users are coming from github authentication (gonna be storing examples
    in Gists). I'm currently storing the users at the root of my firebase
    collection under the key 'users'. I'm using their username as the key for
    each user to make it easy to get a user's profile. Since I was using the
    username as the key, I didn't make a 'username' key in each user's profile
    (felt like that was duplicating for no reason... but if ANY of this is
    funky, or not how you would recommend doing it, please LMK I am open to
    change anything and everything).

    My current issue is that users.$id doesn't appear to be working for me
    (thinking that may not be how I should get the username here). Also, the
    point of the resolve was to load the user's list first, then call the
    controller and load the template into view. It seems like that is not
    happening with the way things are set up.

    As I said, in this case, the user's list can be read only, and I'm not
    worried about updating them live if a user is added while someone is
    looking t the list. So what I want to know is, what's the best way to
    accomplish this?


    I do have a slight curve ball (second scenario I might as well find out
    about)... I'm planning to do a very similar thing to this, but to list all
    the examples (will be a collection like the "users", at the root of my
    firebase collection)... BUT, this time I will be wanting the examples list
    to update live (I won't need to write back to the list from this page.. but
    I would like read the "examples" live, in case examples are added while
    looking at the list. Because I want this updating live here, I'm guessing
    I can just take the code out of what would have been the resolve function,
    and user the identical code inside my controller.


    Needless to say this app is in very early stages of development, and I
    haven't used firebase in like 8 months (and only briefly played around with
    it then). I would love for you guys to critique every little thing you
    can, and recommend what you would consider the "best/correct" way of doing
    the tasks I am currently trying to achieve.


    Thanks in advance for the help. I am loving Firebase, just need to get
    comfortable with the basics so I can really rock and roll on this project.

    Bob
    --
    You received this message because you are subscribed to the Google Groups "Firebase + AngularJS" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to firebase-angular+unsubscribe@googlegroups.com.
    To post to this group, send email to firebase-angular@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-angular/e367ef5f-28fe-47c0-bc3d-70d75d659cfa%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupfirebase-angular @
postedAug 10, '14 at 6:35a
activeAug 11, '14 at 5:56p
posts8
users2

2 users in discussion

Bob Monteverde: 5 posts Michael Wulf: 3 posts

People

Translate

site design / logo © 2021 Grokbase