Angular Example App

243 views
Skip to first unread message

Mike Milano

unread,
Oct 13, 2014, 11:16:21 PM10/13/14
to loopb...@googlegroups.com

The documentation here refers users to that github project.

http://docs.strongloop.com/display/LB/AngularJS+JavaScript+SDK#AngularJSJavaScriptSDK-Exampleapp

"Check out the access-control sample application for a complete application with a LoopBack server application and an AngularJS client app."

It would be great to have an AngularJS example.







Raymond Feng

unread,
Oct 14, 2014, 1:07:38 AM10/14/14
to Mike Milano, loopb...@googlegroups.com
Please check out https://github.com/strongloop/loopback-example-angular-starter.

Thanks,

---
Raymond Feng
Co-Founder and Architect @ StrongLoop, Inc.

StrongLoop makes it easy to develop APIs in Node, plus get DevOps capabilities like monitoring, debugging and clustering.

--
You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike Milano

unread,
Oct 14, 2014, 1:26:22 AM10/14/14
to Raymond Feng, loopb...@googlegroups.com
Thanks Raymond but I was looking for access related examples.

I hadn’t used 2.0 with AngularJSj before, but I found what I needed in the lb-services.js file.  In particular, the LoopBackAuth service for current user.

In case it’s helpful to anyone, here’s how I’m handling an app that requires login. I only saw the v1 examples previously, but since I’m using ui-router, I had to listen to a different event. I’m not sure if there’s a better way, but this works.


angular.module('myapp.auth', [])
  .config(function($httpProvider, $stateProvider) {
    $stateProvider.state('login', {
      url: '/login',
      templateUrl: 'views/login.html',
      controller: 'LoginCtrl',
      anonymous: true
    });
  })
  .run(function($rootScope, $location, $state, LoopBackAuth) {
    $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams){
      if (!LoopBackAuth.currentUserId && !toState.anonymous) {
        event.preventDefault();
        $state.go('login');
      }
    });
  });


Matthew Woolnough

unread,
Oct 14, 2014, 4:35:09 AM10/14/14
to loopb...@googlegroups.com, ray...@strongloop.com
Hi Mike, 


Matthew

Felipe Figueroa

unread,
Oct 15, 2014, 6:29:03 AM10/15/14
to loopb...@googlegroups.com
That example used Loopback 1.x, so even if it was neat, it wasn't really helpful for newcomers like us. In fact, "learning" from this tutorial 3 weeks ago messed up some of what I really knew. I was like "so, there shouldn't be a /server folder, and the app should go in the root". Then I found out that most of that stuff was no longer valid.

12 days ago they cleaned much of that legacy code (specially in the client folder) so you'll have to wait until (and if) there comes a functional 2.0 example for access control.

Manuel

unread,
Oct 15, 2014, 6:37:55 AM10/15/14
to loopb...@googlegroups.com

I forked the loopback-angular-admin project a month ago and made lots of improvements with my team, it's even using lb2.0, you can find it athttps://github.com/idbaigorria/loopback-angular-admin/tree/fiscalizacion

Simon Ho

unread,
Oct 15, 2014, 3:50:38 PM10/15/14
to loopb...@googlegroups.com, ray...@strongloop.com
The access control example has been updated for LoopBack 2.x. You can find it here: https://github.com/strongloop/loopback-example-access-control. Its not specifically for Angular, but shows you how to use various access control mechanisms. I will be putting up poll soon to allow everyone here to vote on the examples they want to see. Your case for loopback-example-angular-login sounds like a good candidate. ;) Anyways, let me know if you have any more trouble after reviewing the access control tutorial.

dou...@dougcorrea.com

unread,
Oct 20, 2014, 12:57:53 PM10/20/14
to loopb...@googlegroups.com, ray...@strongloop.com
Hi, 

I think another good candidate is something like loopback-example-angular-social-login to implement loopback-passport also.

Douglas

Simon Ho

unread,
Oct 20, 2014, 8:57:35 PM10/20/14
to loopb...@googlegroups.com, ray...@strongloop.com
Good news is that I will sticky a poll on the front page soon. This means the community can vote on what examples I do next! I will add your suggestions as candidates. Thanks again.
Reply all
Reply to author
Forward
0 new messages