opitzconsulting / jquery-mobile-angular-adapter

jquery mobile angular adapter
MIT License
517 stars 114 forks source link

Need an explanation about declaring routes #173

Closed untied closed 11 years ago

untied commented 11 years ago

Hello. Can you please clarify one moment about declaring routes?

What is the use of declaring AngularJS routes, like:

$routeProvider.when('/someFolder/page1.html', { templateUrl:'#page1' });
since we still have the common jQuery Mobile hash-oriented navigation, like:
<a href="#page1">page 1</a>
???

This hash-oriented navigation operates without any relation to AngularJS routes, it is impossible to employ views (directive ng-view) and controllers... So what is the idea of declaring routes if navigation works without such a declaration?

Or maybe I've missed something important?

tbosch commented 11 years ago

Hi, internally we are using angular's routes also for the default case, i.e. an url of #page1 will load the internal div with id page1. For this, we use $routeProvider.otherwise.

Custom routes are nice if you want to use the same page for multiple urls with parameters, e.g. /user/1 and /user/2 which should all use the template from #userPage.

However, if you are not using url parameters, then you can stick to the default routing, you are right.

Tobias

tbosch commented 11 years ago

Hope this helped. Closing this.