问题
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