Link route to directive? Or another way? - angularjs

I have an unusual question.
I have this old page that I want to convert to angular.js.
http://transience.me/TD/
I have 5 pages worth of html loaded on one page and the only visible portion is the part that has been navigated to. i.e. home is at x position 0, about is at x position, 1024, projects is at x position 2048, etc...
Right now though there's no way to link to the individual sections. You have to land at the home and then navigate to the section you want to visit.
However I want to add a deep linked url: url/#/home, url/#/project, etc.. to correspond with the navigation which triggers a change in page position.
Is there a way to link the router in angularjs to a directive so that instead of loading an html template it triggers a new dom behavior?
Thanks for any help!

I think ui-router would help you greatly.
It uses a $stateProvider which allows you to change the url without reloading the entire template. You can add transition effects and to move between pages and it will keep all back buttons, page refreshes, etc.
Check out the ui-router demo

Related

Get name of selected item of list elements in same page by disappear of listed elements , using $stateProvider concept in angularJS

I am newbie to angularJS,can anyone provide me an example regarding my concept,i am unable to implement this routing of parent element with node of child elements with $stateProvider routing concept.
when i click on trees,it has to display fruits and flowers in nav bar with active mode of fruits,flowers list in another page,we can redirect to both pages.
when i click on mango it has to display its div along with its name,i did some work on it,can anyone help to reach my work completely?
There are several issues which you need to address.
index.html
instead of ref, use ui-sref.
app.js
Here state should be exactly what you are specifying with the ui-sref.
I see templateUrl given by you are missing.
Check this simple article to start with ui-routing

Change page without changing location.path or location.url

Is it possible for AngularJS to change your page without changing your location path/url?
Like for instance I have a table page that has the path/url <host>/<app>/table and when I click on the entry in the table, it goes to an element detail page but the path/url stays the same (since this operation is confined anyway to the /table path) ?
you can always use ng-include to load a template on a specific part of your page.
that would change the content of that part without changing the url of the page.

Backbone history appends route to URL twice

This is a followup to my earlier question, Backbone routing/history issue with Jekyll static pages.
I'm building a simple, static site with Jekyll and using Backbone to do some routing. All of my pages are separate HTML files. I handle navigation by watching my <a> elements for clicks, and using jQuery.get to load up the new page and replace the content. A bit unusual, I know, but I want a single page in order to provide smooth transitions and preserve my webfonts.
The issue is that when I start from any page other than my root url — let's say /page1 — navigate around, and then use the browser's back button to return to my first page, I get a 404: /page1/page1 not found. Here's some example navigation:
localhost/page1/ <- entered into address bar
localhost/page2 <- linked from an <a>
localhost/page1 <- linked from an <a>
localhost/page3 <- linked from an <a>
localhost/page1 <- clicked back button; works fine
localhost/page2 <- clicked back button; works fine
localhost/page1/ <- clicked back button; 404 at /page1/page1
Note that returning to page1 from deeper within the history works fine; it's only my starting route that gives me grief. I think it might have to do with the trailing slash appended by the browser when I manually enter that first URL, but I'm not sure how to resolve this.
I posted my relevant backbone code in this JSFiddle. As you can see, my router is initialized with silent: true and root: '/'.
Not sure what to do here — been banging my head against the wall for weeks!

AngularJS - using Angular UI router - how to fetch the next content via AJAX without removing the current content

I'm using Angular UI router in my app. This is what I'm doing.
A main view contains a child view and a div container for "pagination"
By default, initially, a first set of contents is loaded
When a user clicks on "next page", next set of contents is loaded (with the URL also being changed to /content/2 (where 2 indicates the next page number)
All is working well, but each time the contents are loaded, it goes "blank" before it loads. So it seems like it's reloading the view (which is obvious).
What I would like to do is reload the content without having that "blank" page. How can I achieve this?
At first thought, I think you could you the same approach as infinite-scroll, which is what I'm using. So you make a GET request to the server to get new content and push it to the list on clicking 'next'. However, since the URL changes also. This will cause the controller to be reloaded. You can actually bypass this by setting reloadOnSearch to false.

Backbone.js: How to utilize router.navigate to manipulate browser history?

I am writing something like a registration process containing several steps, and I want to make it a single-page like system so after some studying Backbone.js is my choice.
Every time the user completes the current step they will click on a NEXT button I create and I use the router.navigate method to update the url, as well as loading the content of the next page and doing some fancy transition with javascript.
Result is, URL is updated which the page is not refreshed, giving a smooth user experience. However, when the user clicks on the back button of the browser, the URL gets updated to that of a previous step, but the content stays the same. My question is through what way I can capture such an event and currently load the content of the previous step and present that to the user? Or even better, can I rely on browser cache to load that previously loaded page?
EDIT: in particular, I'm trying something like mentioned in this article.
You should not use route.navigate but let the router decide which form to display based on the current route.
exemple :
a link in your current form of the registration process :
<a href="#form/2" ...
in the router definition :
routes:{
"form/:formNumber" : "gotoForm"
},
gotoForm:function(formNumber){
// the code to display the correct form for the current url based on formNumber
}
and then use Backbone.history.start() to bootstrap routing

Resources