How routing and Ajax are different in angularjs

江枫思渺然 提交于 2019-12-25 04:26:28

问题


I am new to angular and I am trying to understand the routing concept , but I am getting confused routing is used to load some parts of the html from server if templateUrl is given in when method but even ajax does that it loads data in the form of JSON, XML or HTML from the server without reloading the entire page.So how are they different ?


回答1:


Routing is the process where a piece of software looks at the URL and uses it to decide what bit of code to run.

In Angular, quite a lot of time, the "bit of code" that gets run will include an Ajax request to get some data from the server.

Routing is not an alternative to Ajax, it is something that can trigger Ajax.



来源:https://stackoverflow.com/questions/38848006/how-routing-and-ajax-are-different-in-angularjs

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