ASP.NET MVC和角JS临界点 [英] ASP.NET MVC and Angular JS tipping point

查看:120
本文介绍了ASP.NET MVC和角JS临界点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个相当大的ASP.NET MVC Web应用程序。在一些网页上,我想利用AngularJS。

I want to create a largish ASP.NET MVC Web application. On some pages I would like to utilise AngularJS.

这个应用程序将不会是一个SPA。

This app will not be a SPA.

在什么时候这成为一个问题?例如在什么时候运行实际上是两个MVC范式成为一个头痛?

At what point does this become a problem? For example at what point does running effectively two MVC paradigms become a headache?

或者是它的情况下,只要你有什么使用ASP.NET MVC(标准操作方法等),什么是采用了棱角分明的JS然后并排ok了两个运行方不给你大量的code之间明确的划分组织/可维护性头痛?

Or is it a case of as long as you have clear delineation between what's using ASP.NET MVC (standard action methods etc) and what's using Angular JS then the two run side by side ok without giving you massive code organisation/maintainability headaches?

任何智慧的欢呼声。

我很想约翰·帕帕斯意见!

安德鲁

推荐答案

我使用ASP.NET MVC一起AngularJS了相当大的内部应用程序。我们真的不使用ASP.NET MVC的很多功能超出了基本的页面模板和脚本捆绑 - 所以一切从客户端是通过AngularJS和客户端的路由控制 - 除了一些区别,我们已经模块之间的'造我们想要一个不同的NG-应用程序的每个,具有不同的脚本沿着依赖的应用程序。

I use ASP.NET MVC alongside AngularJS for a fairly large in-house application. We don't really use many features of ASP.NET MVC beyond the basic page template and script bundling - so everything from the client-side is controlled by AngularJS and client-side routing - except for some distinctions we've made between 'modules' of the app where we wanted a different ng-app for each, along with different script dependencies.

如果你正在寻找采取一个页逐页优势AngularJS的话,我觉得你有一点问题都没有。只要你引用(模块,控制器等核心都脚本AngularJS,你的AngularJS脚本)脚本正确,则你可以开始使用NG-应用,NG-控制器等装饰元素,这将只是工作。你可以使用@section声明插入相关.cshtml网页相关AngularJS脚本。

If you're looking to take advantage of AngularJS on a page-by-page basis then I think you have no problem at all. As long as you reference the scripts (both core AngularJS scripts, and your AngularJS scripts for modules, controllers, etc.) correctly then you can just begin decorating elements with ng-app, ng-controller, etc. and it will just work. You could insert the relevant AngularJS scripts for relevant .cshtml pages using a @section declaration.

如果需要服务器端和客户端路由的混合它只会更加复杂。那么这将是精心构建ASP.NET MVC的路线,提供在需要时SPA功能的情况。

It will only be more complicated if you need a mix of server-side and client-side routing. Then it will be a case of carefully constructing ASP.NET MVC routes to deliver the SPA functionality where needed.

这篇关于ASP.NET MVC和角JS临界点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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