I am working on an application which uses angularjs 1.6 for the frontend and codeigniter for the backend. Till now the home page in my application had the login form and the logic for that functionality was written in homeCtrl.js. Due to new design changes for the application, the login form is now part of the header. So I am clueless about how to implement the login functionality throughout the application as the header will be a part of all the pages. Can I use the existing code without breaking the functionality as I have a deadline to meet.
Yes, you can implement this logic. Use proper routing.
You can refer to this link.
Make use of UI-Router
This article makes use of ui-router library which you need to include.
In normal scenarios you will be having only simple states and one
state will be assoaciated with one view. But here you can configure
multiple views with your state.
UI Router with Multiple Views
In your case, for the home page header will contain the login form.
And for the other pages it will contain the actual header or whatever
you want. You can configure as many sub screens as you want.
You may get the UI-Router cdn path here
I have complete angular js working application.But i have a challenge ahead in that single page has to be made which will open on click of link.
Now the challenge for me is that if user is not logged in(Session not created) and someone trying to access any link it will redirect to login page,but in current case since i dont want user to be logged in and directly taken to that page and let him perform actions.
One simple solution for me was to create different application but i want to utilize the contents and code of current application.
Any one has faced any situation like this before,If yes then is there any possible way?
I am pretty new to AngularJS and although I understand basic concepts (I also have years of experience in JS) this is a bit of problem to me.
I want a login form that opens a dashboard with multiple sections accessed from a lateral menu (or breadcrumb element)
For the login part I used some code from Angular Registration Login Example
but now I want to open the dashboard and enable the route segments (using http://angular-route-segment.com/) for the dashboard navigation menu. How would I go around this?
Can I do this in the dashboard's controller, create another module, or how should I separate login from dashboard?
Would I do it globally, in app.config for all routes and segments?
Maybe you know some examples I could use as reference. I guess this is something that you find in many applications
My basic question is;
How to implement two seperate page(everything is different,css, js, html file) login and home page in 'Just using' client side? I mean think like a classical login mechanism. User will come to login page and give a credential,then 'redirect' to home page. I need to seperate this two page because themes and the other things are different. Also after this step (login step) I want to continue with SPA with Angularjs,mongoDb,socket.io and Nodejs.
In stackoverflow I found couple implementation with ASP.NET Web API or other backend technologies. But I don't want to use ASP.NET framework for just login page. As I said I will not need ASP.NET framework after user logged in.
Also I found couple authentication implementation on Angular.js but every example using same templates and styles for login page and home page.But I cannot use these styles and html code cause dom's are too different.
So any suggestion or idea for this problem will be great. Thanks.
I'am doing my first AngularJS project with ASP.NET Web API backend. What I am trying to do is, whenever a user visits www.mydomain.com, a login page (index.html) will displayed. After successfull login, he will be redirected to the dashboard.html (this is the shell page, partial views go here). My project structure is shown below-
I am confused about some issues:
Is this the best/common practices what i am trying to do in above?
As because dashboard.html is the main page, should i place app.js on dashboard.html?
If i put app.js on dashboard.html, will index.html (login page) have another app.js (i.e. loginApp.js)?
How should I manage the login state i.e. IsUserLoggedId, UserId etc in angular part?
This question may be silly. I googled, but did not find any example/article addressing such issue.
Would you please help?
Thank you in advance.
I am not sure how ASP.NET deals with it, but to my knowledge ASP.NET is just a server side framework whereas AngularJS is client side framework.
These two framework solve different problem, but has some overlapping features.
If you start using angularjs, then most of the time you will deal with the term "Single Page Application (SPA)".
There are different approaches in how you can handle the url redirection after login. I will just show you two example. There are many more how you can handle the user authentication and session.
First Approach:
In SPA, most of the time browser will change the url route and state directly in the page itself without making the entire page request from the server.
With that said, your dashboard.html will most likely be come a static template file which will be loaded from the browser directly. (i.e. the server does not dynamically parse the dashboard.html but only serve as a static file). Upon the user login, the angularjs will fire a asynchronous HTTP request into the ASP.NET authentication end point. A successful login may return a token to the browser, and the client will use it to manage the user session. At the same time, the Angular will have to change the route to /dashboard/. Notice that that the entire flow happens transparent to the user, it does not fire a full page HTTP request.
Second Approach:
Alternatively, if you choose to redirect from the server, you will have to send a HTTP Redirect 302. and since HTTP redirect will eventually call make a full HTTP request to /dashboard/, and it will then have to reload and bootstrap the angular app.js from the browser again. In this case, the user will have to wait for the dashboard page to be processed by the server upon login
Issues:
Is this the best/common practices what i am trying to do in above? there are many approaches, I think it is best to find the one that works for you. If you have a RESTful API, then you might want to have a look at the SPA approach in more detail.
As because dashboard.html is the main page, should i place app.js on dashboard.html? in SPA, you don't need to load app.js twice. but if you use the second approach, you have to reload the app.js again.
If i put app.js on dashboard.html, will index.html (login page) have another app.js (i.e. loginApp.js)? depends on your approach as stated above
How should I manage the login state i.e. IsUserLoggedId, UserId etc in angular part? Authentication Strategy, UNIX style authorization
There are more official guide that can help AngularJS Developer Guide.
Hope this helps you to integrate with the ASP.NET authentication mechanism.
you should have multiple shell pages. this link can help you...
refer to Multiple Shell Pages part.