How best to include an angularjs page on demand? - angularjs

I'm working on my first AngularJS app it I want it to be as efficient as possible. I have forms I want to use stand-alone and also to reuse within other pages. I'm trying to learn the best way to do this.
For example, consider this snippet from my home page:
Welcome, {{name}}. Click here to update your address data.
At this point, I have only loaded the data for the person's identity. I don't want to request the address data unless the user clicks the here link. Then (and only then), I want to retrieve the address record and load an address form for the user to update.
The form I want 'stands alone' in another angular 'page,' e.g., myApp/address/person_id, but I don't want to redirect the user to that page. I just want to 'include' its form.
Can anyone suggest best practice(s) for this?

Related

How to create module which can surpass authentication in angular js?

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?

Send form data from one page to another page using angularjs

Hello can any one please tell me how to send on form data to another by clicking submit button using angular JS.
There are three ways to do that.
If you are using SPA flow for your website, you can make a service for data that are to be shared among pages. Redirection will only change the hash value of URL and landing page will still have those data from service.
Second is to use the hash value for data as lets say that you are redirecting from baseURL/test1 to baseURL/test2 so instead of redirecting to baseURL/test2, you can redirect to baseURL/test2#/data=* , * representing the data. The redirection will still happen but now you can also get the data.
Third is to use local storage or webSQL ( although limited browser support for webSQL), to save the data and then retrieve back on the next page.
While I will stick to the SPA flow for my angular website and use a service to pass on the data. There is also a way to assign data in $rootScope but that is just not a good practice to pass on data from one page to another.

ng-admin redirect to specific page after element creation

I have a small admin page setup with ng-admin. Creating elements works without any issues.
What I want to achieve though is that I sent the user to a different page where he can perform some action that will alter the created item(scraping some data elsewhere for the element and asking if its correct).
Is there a way to overwrite the custom route that is on the submit button in ng-admin to sent the user to a custom page, also inside of ng-admin?
I would like to not tinker with the ng-admin code to not break the functionality on other elements pages.
Tere is no built-in way to do that in ng-admin 0.9. But a recent addition to the 1.0.0-dev branch (view.prepare()) might help you, see https://github.com/marmelab/ng-admin/pull/756.

AngularJS, Deeplinking within a view

Objective
I am currently building my first web application with AngularJS. I need to know the correct way to deeplink to content within a view.
http://signalreview.2mellow.com/ this is the current build.
Description of problem
For example, You can search for mcdonalds, spokane, When this happens I want the address bar to reflect the search that was just done such as #/search/mcdonalds%20spokane so that a user can link a search to someone else. I understand how I can get the data out and initiate the search. I just don't understand how I should be utilizing Angular JS to accomplish the goal.
From my research I have determined that nested views is not a good idea.
Also I have plans to have it so that if you click a map marker for a place that has been reviewed (stored locally in the db) It would put the id in the address bar so that location could then be linked to someone else or you could bookmark it.
Contstraints
The idea is that everything is done on one view with a persistent google map however there are certain states that are saved within that view.
Conclusion
Am I approaching this the wrong way?

Building my own `like` system

I am thinking to build my own like system, as a way of learning various technologies including Javascript; and to gain a better understanding of authentication and XSS.
Use-case:
Unique ID generated atop a little bit of Javascript code, for embedding in any website
When unique user presses this like button, a +1 is triggered to the 'score' of that UID
On unique user's profile, display what they like'd
I'm unsure as where to start... how would I go about building this system?
Building such system is easy. Securing it properly, making it flow nice and be easy to integrate is the hardest part. You should ignore the latter 3 for now. I would start with a JS file that searches the DOM for any elements with the ID of "mylike" (for example) which inserts a button on to said page. Once a user clicks the button it simply does an AJAX post back to your server containing information like the page title and page URL. I think it may be best for your backend to generate the ID, maybe an algorithm based on the title + URL.
To include user data to know what user liked what I'd suggest a persistent cookie that has a session variable to link to a user in your back end. Simply pull the cookie out using JavaScript and send the cookie along with the AJAX request.

Resources