How to structure routing in an Angular js and Lithium app?

情到浓时终转凉″ 提交于 2020-01-05 05:47:06

问题


So I am planning out an app of moderate complexity using Angular for the frontend and Lithium for the backend. I'm full of questions at this point, but for this post I would like some ideas on templating. Both lithium and Angular have the capacity to handle the entire view layer, but I'd rather treat it like a single page app, so Angular will handle this.

Now how would I handle routes? Would Lithium basically be dumb of the current routes beyond the index? Should API endpoints have a special url scheme separate from the view URLs?

This is how I am thinking now::

theapp.com/dashboard/calendar/event/eventID :: for a view handled by Angular & theapp.com/api/event/eventID :: for an API endpoint

I'm quite new to building something this complex so please forgive me if this is a simple question. :)

Am I totally off the mark?


回答1:


This presentation should be helpful: http://li3-angular.lithium-framework.com/

What you're planning is the way to go: Li3 expose a json api, and Angular handles your routes and views. Your URL scheme should follow REST principles.

  • li3_resources will help you to build a RESTful api: https://github.com/nateabele/li3_resources
  • Angular UI router should help you with your routes: https://github.com/angular-ui/ui-router


来源:https://stackoverflow.com/questions/18338840/how-to-structure-routing-in-an-angular-js-and-lithium-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!