首页 \ 问答 \ 为什么MEAN.js applications'URL以#开头!(Why MEAN.js applications'URL start with #!)

为什么MEAN.js applications'URL以#开头!(Why MEAN.js applications'URL start with #!)

我刚用MEAN.JS开始了我的第一个MEAN应用程序构建。 在发现了mean.js如何组织应用程序之后,我想知道为什么URL以/#!/开头。

例如,对于我想要的登录页面:

http://example.com/login

代替:

http://example.com/#!/login

所以我查看了Express和Angular文档并没有发现它。 我还阅读了完整的MEAN.JS文档,但仍未找到任何内容。

在Angular的模块配置路由文件中,URL不是#!前缀#!

users.client.routes.js:

...
state('login', {
    url: '/login',
    templateUrl: 'modules/users/views/authentication/login.client.view.html'
}).
...

所以我最后有两个问题:

  1. 为什么网址会这样开头? 这有什么好的做法吗?
  2. 如果这不是一件坏事,我该如何以及在哪里更改这些网址?

I just started my first MEAN application build with MEAN.JS. After discovering how mean.js organise the application, I wonder why URLs start with /#!/.

For example for the login page I would like to have:

http://example.com/login

instead of:

http://example.com/#!/login

So I looked to the Express, and Angular docs and found nothing about it. I also read the full MEAN.JS docs but still found nothing.

On the Angular's modules configuration routes file, URLs are not prefix with #!:

users.client.routes.js:

...
state('login', {
    url: '/login',
    templateUrl: 'modules/users/views/authentication/login.client.view.html'
}).
...

So I end up with two questions:

  1. Why the URLs start like this ? Is there a good practice behind this ?
  2. If it's not a bad thing, how and where can I change these URLs ?

原文:https://stackoverflow.com/questions/28569145
更新时间:2024-01-17 06:01

最满意答案

这两个查询在功能上是否相同?

如果通过等效表示最终结果,则可能是(取决于提供程序如何实现这些操作),区别在于您使用内存扩展的第二个查询。

我的意思是,查询中“AsNumerable()”的顺序是否会更改从客户端检索的数据项的数量,或者检索它们的方式?

是的,在第一个查询中, WhereOrderBy将被转换为SQLSelect将在内存中执行。

在第二个查询中,数据库中的所有信息都被带入内存,然后在内存中进行过滤和转换。


Categories可能是IQueryable ,因此您将使用Queryable类中的扩展。 此版本的扩展接收Expression作为参数,这些表达式树允许将代码转换为sql查询。

AsEnumerable()将对象作为IEnumerable返回,因此您将使用Enumerable类中直接在内存中执行的扩展。


Are this 2 queries functionally equivalent?

If by equivalent you means to the final results, then probably yes (depending how the provider implements those operations), the difference is in the second query you are using in-memory extensions.

I mean, does the order of "AsNumerable()" in the query change the number of data items retrieved from the client, or the way they are retrieved?

Yes, in the first query, Where and OrderBy will be translated to SQL and the Select will be executed in memory.

In your second query all the information from the database is brought to memory, then is filtered and transformed in memory.


Categories is probably an IQueryable, so you will be using the extensions in Queryable class. this version of the extensions receive a Expression as parameter, and these expression trees is what allows transform your code to sql queries.

AsEnumerable() returns the object as an IEnumerable, so you will be using the extensions in Enumerable class that are executed directly in memory.

相关问答

更多
  • 我会做 var ids = from o in dbcontext.Orders where o.ID==1 select new { ID = o.ID }; var names = from i in ids.AsEnumerable() select new Order { Name = GetName(i.ID) }; 即在数据库中尽可能多地进行查询,然后仅在C#中执行ID到名称的转换。 I'd do var ids = from ...
  • 是的,这是从数据表中获取前N行的正确方法。 使用CopyToDataTable扩展从查询结果创建新数据表: DataTable dt = dtResult.AsEnumerable() .Take(n) .CopyToDataTable(); Yes, this is a correct way to take first N rows from your data table. Use CopyToDataTab ...
  • 调用AsEnumerable( )不执行查询,枚举它。 IQueryable是允许LINQ to SQL执行其魔术的界面。 IQueryable实现IEnumerable所以当你调用AsEnumerable() ,你正在改变被调用的扩展方法,即从IQueryable方法到IEnumerable方法(即在这个特定情况下,从LINQ to SQL到LINQ to Objects )。 但是你并没有执行实际的查询,只是改变它将如何执行。 要强制查询执行,您必须调用ToList() 。 Calling AsEnum ...
  • AsEnumerable的原因是 当序列实现IEnumerable(T)时,AsEnumerable(TSource)(IEnumerable(TSource))可用于在查询实现之间进行选择,但也有一组不同的公共查询方法 所以当你以前调用Where方法时,你正在从IEnumerable.Where调用另一个Where方法。 那个Where语句是为了将LINQ转换为SQL,新的IEnumerable在哪里使用IEnumerable,枚举它并产生匹配项。 这就解释了为什么你看到不同的SQL被生成。 在将第二个版 ...
  • 第二个更好,第一个做一个选择然后进行过滤,这意味着它必须先从数据库中获取数据,然后将其转换为User对象,然后进行过滤。 第二个将在DB端进行查询,然后将其转换为User对象 可以通过将选择移动到ToList()之前来修复第一个 The Second one is better, the first 1 does a select then does filtering, meaning it has to get the data from the database first to turn it in ...
  • AsEnumerable强制将Join语句执行到LINQ to Objects中。 因此,来自RC_CampaignHubSpokeTbl和RC_CampaignTbl所有数据都将从WCF获取,然后在您的应用程序中组合在一起。 这是必要的,因为WCF调用不支持连接。 要优化您的查询,您可以执行以下操作: que = From CHS In ent.RC_CampaignHubSpokeTbl.AsEnumerable() Join Cam In ent.RC_CampaignTbl.Where( ...
  • 你的理解是正确的。 在调用AsEnumerable ,数据源不能再被查询,并回到简单的“给我所有”模式,这意味着所有的数据都被传输到客户端,并且任何进一步的操作都在本地完成。 这也是查询不能像编写的那样工作的原因:为了使其工作,您在LINQ方法中使用的所有表达式必须可转换为数据源所能理解的任何语言 - 并且由于它是查询提供程序翻译的责任,你也将受到任何程序支持的限制。 在这种特定情况下(假设EF),可以通过手动将属性访问替换为规范函数TruncateTime来修复查询以在可查询模式下工作: .Where(m ...
  • 这两个查询在功能上是否相同? 如果通过等效表示最终结果,则可能是(取决于提供程序如何实现这些操作),区别在于您使用内存扩展的第二个查询。 我的意思是,查询中“AsNumerable()”的顺序是否会更改从客户端检索的数据项的数量,或者检索它们的方式? 是的,在第一个查询中, Where和OrderBy将被转换为SQL , Select将在内存中执行。 在第二个查询中,数据库中的所有信息都被带入内存,然后在内存中进行过滤和转换。 Categories可能是IQueryable ,因此您将使用Queryable ...
  • 它们是不同的扩展方法。 一个是DataTableExtensions.AsEnumerabl e和其他是Enumerable.AsEnumerable They are different Extension methods. One is DataTableExtensions.AsEnumerable and other is Enumerable.AsEnumerable
  • .ToList()将在内存中构建一个新的List并将所有对象存储在其中。 那是不必要的工作; 你应该调用.AsEnumerable() 。 通常,只有在需要多次迭代时(并且只在查询链的末尾.ToList()才应调用.ToList() )。 .ToList() will build a new List in memory and store all of the objects in it. That is needless work; you should call .AsEnumerable ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。