As I am in learning phase of AngularJS, today I noticed one thing about the tutorials avaliable for it.
In the tutorials, the URLs used are hardcoded in the HTML and JS files.
For example: If I have my routes defined like this in my config:
// config.js
$routeProvider.when("/", { // Home Page
templateUrl: basePageUrl,
controller: "Home"
}).when("/searches", {
templateUrl: basePageUrl, // Search Page
controller: "SearchPage",
})
Now in my home.html , if I want to create a link to searches page. I have to do the following:
<!-- home.html -->
<div>
Hello Home
<p> Go to <a href="#/searches">Searches</a> </p> <!-- I had to hard code the link -->
</div>
So, I was looking for a solution so I don't have to hard-code the links in HTML or JS files.
More like, the urls resolution functionality that each Backend MVC framework provides.. e.g
- Django:
{% url %}templetag for HTML andreverse()for python code - Rails:
<%= link_to %>tag for HTML etc..
Is there a URL resolution functionality provided by AngularJS or any plugin ?
Note: I can implement something similar by storing JS variables/object for urls, but that doesn't look a good design to me