AngularJS中的路由和Ajax有何不同 [英] How routing and Ajax are different in angularjs

查看:64
本文介绍了AngularJS中的路由和Ajax有何不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是angular的新手,我想了解路由的概念,但是如果在when方法中给出templateUrl,但路由被用来从服务器加载html的某些部分,即使ajax也会加载数据,这使我感到困惑以JSON,XML或HTML的形式从服务器发送而无需重新加载整个页面.那么它们有何不同?

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 ?

推荐答案

路由是一个过程,其中一个软件查看URL,并使用该URL来确定要运行的代码位.

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

在Angular中,很多时间,运行的代码段"将包含一个Ajax请求,以从服务器获取一些数据.

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.

路由不是Ajax的替代,它可以触发Ajax.

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

这篇关于AngularJS中的路由和Ajax有何不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆