ASP.Net MVC的验证与角VS剃刀 [英] ASP.Net MVC validation with Angular VS Razor
问题描述
ASP.Net MVC与自定义属性在模型和剃须刀在一起,让您只需编写一个HTML帮助像@ Html.ValidationMessageFor(型号=> model.MyAttribute)
验证每个字段。
AngularJS打算呈现在客户端上的一切,所以我们不必剃刀和所有自由生成的JavaScript验证器的访问。我们必须再次code一切由手,我们没有保证,这种验证是在服务器端验证,这是我们不得不用剃刀同步。</ P>
我们将如何克服这种差距?
这解决了我的问题:
https://github.com/alisabzevari/ngval
如果我们要深究下去(我现在不需要),我们可以有这样的:
https://bitbucket.org/asiemer/angularjs.mvc/wiki/Home
ASP.Net MVC together with Custom Attributes in your model and with Razor, lets you just write an HTML Helper like @Html.ValidationMessageFor(model => model.MyAttribute) to validate each field.
AngularJS intends to render everything on the client side, so we don't have access to Razor and all the javascript validators generated for free. We have to code everything again by hand, and we don't have the guarantee that this validation is in sync with the server side validation, which we had with Razor.
How will we overcome this GAP?
This solves my problem:
https://github.com/alisabzevari/ngval
If we want to go deeper (which I don't need now), we can have this:
https://bitbucket.org/asiemer/angularjs.mvc/wiki/Home
这篇关于ASP.Net MVC的验证与角VS剃刀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!