Should I use Angular’s ngRouter in Framework7?

TL;DR

No, you shouldn’t use ngRouter with Framework7. Use ajax pages and set pushState:true instead!


I’m getting quite a lot of questions regarding the implementation of navigation in Framework7 apps with Angular.js. How do I use ajax pages with Angular? Does ngRouter work with F7? How can I get the back button in the browser to work in F7? And so on…

Best practice for ngRouter with F7

I don’t know if there is something like a "best practice" but so far for me it seems like it’s best to let F7 handle navigation as well as content integration. Mixing ngRouter with F7’s navigation system does not work well. There is no real point in using ngRouter anyway. Framework7 does an excellent job of fetching content via ajax pages and display the data at the right spot. You might want to enable the browser’s back button capability though by setting this option when initializing your app:

var myApp = new Framework7({
  pushState: true
});

Learn more about Ajax Pages with Angular

Leave a Reply