Hi,

I've just got ui-router set up and I'm going to give the solution you 
suggested a try. Does this mean that your stateProvider has a lot of 
duplicate entries for all the ui-view elements? Are you including them for 
each state?

Stephen

On Wednesday, May 21, 2014 5:57:59 PM UTC+1, Eric Eslinger wrote:
>
> I'm using ui-router to accomplish this. Basically, I created a top-level 
> template in my index.html (equivalent) file that includes a header, footer 
> and body ui-view element. Then in all my routes, I have templates shoved in 
> there for app-header.html, etc.
>
> I have a special loginrequired route that loads different header/footer 
> templates (which make use of no logged-in information like username). Then, 
> when I detect that the user's not logged in, I just issue a $state.go 
> 'loginrequired'. I do this in several situations: when the user's cookie is 
> unset and when any of my $http calls return 401. That's because my login 
> process generates a bearer token that I stash in a cookie, so either 
> there's nothing there to start, or the bearer token has expired and the 
> user has to log in again.
>
> That loginrequired page handles the login stuff ("click here to open a 
> google oauth session in a new tab", more-or-less).
>
> UI Router makes this a lot easier, but you can do it with ngRouter as well 
> IIRC. I definitely suggest you separate your views into logged-in and 
> not-loggedin templates unless they're complex and share a lot. In that 
> case, that feels like a definite use for ui-router and multiple named views.
>
> e
>
>
> On Wed, May 21, 2014 at 9:08 AM, Stephen Adams 
> <[email protected]<javascript:>
> > wrote:
>
>> Hi,
>>
>> I'm working on first big AngularJS project and one of the first tasks I'm 
>> tackling is creating the login mechanism. The way I want the page to work 
>> is, when the user is logged out they see the main login screen, once they 
>> have successfully logged in the main template shows the full application UI 
>> (header, navigation etc).
>>
>> So far I have created all my pages to load through ngView, but when I 
>> load the loginView I still have all the UI components in the main template 
>> (navigation etc). My plan was to create a login service that, for now, just 
>> checks that the user has submitted the login details. Then is sets a 
>> property of 'loggedIn'. 
>>
>> I was then going to use this loggedIn property to check against in each 
>> UI element, so if loggedIn == true the ng-show will display the UI element 
>> if not the the UI element is hidden.
>>
>> The main problem I'm trying to tackle is have one main template and 
>> loading the login as a view within that template. Ideally I'd have two 
>> templates, one for the loggin and one for the main template. 
>>
>> Any suggestions on the approach I'm taking?
>>
>> Thanks
>>
>> Stephen
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "AngularJS" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/angular.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to