75

If you're building a single page application (SPA), then you probably don't need the "MVC" in ASP.NET MVC. Views, especially dynamic views, are likely delivered/manipulated client-side. Angular handles that just fine. But maybe you don't want a 100% SPA. Then what? Imagine instead 10 pages, but 10 pages that are very dynamic. After a user logs on, there's a ...


59

Allow me to disagree with Michal Charemza answer. Although his answer is theoretically correct, it is not very practical for the real world. I am saying that because I used to think like that and tried to enforce it on a large real world app that myself and my team are building and it just became too troublesome. The analogy to the HTML language is not ...


27

You're right, there's many options at play. A controller is a good place to start writing something new in angular. Tying a controller to a piece of markup lets you use angular's already existing library of directives with angular's existing services. After a very short while of living with this, you'll realize your controller has gotten too large. Well ...


24

A directive is best (as a rule-of-thumb) when it's short (code-wise), (potentially) re-usable, and has a limited a scope in terms of functionality. Making a directive that includes UI and depends on a service (that I assume handles connection to the backend), not only gives it 2 functional roles, namely: Controlling the UI for display/entry of data for the ...


21

It seems to me that single-page apps draw a line in the sand of progressive enhancement. Where before we might try to work around the fact that implementations and features vary between browsers going back for decades, SPAs assume that there's a certain baseline that we can reasonably agree most visitors of a given site will meet. I don't think the two are ...


21

Angular is for Single Page Applications, forms are sent using AJAX to avoid the page to be reloaded. For sending multipart forms with AJAX, your browser need to support FormData(IE10+): http://caniuse.com/#search=FormData https://developer.mozilla.org/en-US/docs/Web/API/FormData ngModel doesn't work with input[type="file"], so you have to create your own ...


19

MVVM is intended to be used where complex user interactions using high-fidelity UI's are needed (i.e. WPF). MVVM is targeted at modern UI development platforms (Windows Presentation Foundation, or WPF, and Silverlight) in which there is a user experience (UXi) developer who has requirements different from those of a more “traditional” developer (e.g. ...


17

You can certainly use any mix of client-side rendering and server-side rendering, but I would recommend against trying to mix ASP.NET MVC helpers with AngularJS directives. It might seem like a good idea at first because you're already used to using those helpers and you don't have to write "raw html", but they defeat the some of the purpose of what client-...


17

ASP.NET MVC is a server-side framework; it doesn't care what JavaScript libraries do you use. AngularJS is a client-side library, which doesn't care what server-side technology powers the website—it can be Python, ASP.NET MVC, or even the plain old bunch of static HTML files stored directly on disk. ASP.NET MVC and AngularJS are both compatible, and there ...


15

Sometimes MVVM can be a trap. From my experience it favors CRUD-like applications (forms over data) versus more task-oriented UIs. I'm not saying that it implies bad architecture for the back end/others layers in the application but I have seen a lot MVVM applications coming with "DDD light" architecture. I don't know why exactly maybe because the binding is ...


13

MVVM is a band-aid for poorly designed data binding layers. In particular, it has seen a lot of use in the WPF/silverlight/WP7 world because of limitations in data binding in WPF/XAML. From now on, I'm going to assume we're talking about WPF/XAML since this will make things more clear. Lets look at some of the shortcomings that MVVM sets out to solve in WPF/...


13

For AngularJS, I think the best place to start is $scope.$apply(), as this ties together changes to the model and the view. From there, move to one of the simpler directives, perhaps ng:value. Keep the documentation open while you're doing this.


13

First of all, no Java does not have enforced coding standards. Anything you can make work in JavaScript I can also make work but look worse in Java. Working, in any language, doesn't ensure that it's well written. Need proof? See Code Golf. Coding standards exist in you. Not the language. You're likely feeling this way because you've looked at enough Java ...


12

You have two options. Create separate mywebsite.api and a mywebsite.app projects in your solution. Advantages Proper separation of concerns. You can deploy updates to your api and your front end independently. Architecture of sites can be changed independently (i.e. you can update your api to run on asp.net 5 without affecting the website) Cleaner ...


9

The thing is - if you write clean and modular code in a complex applications (I mean application with lots of UI functionality, since the question was particulary about JS and MV* frameworks), you will realize, eventually, that you are doing an application in MV* style. It could have another implementation and code look, but it will be MV*-application. I ...


9

If you are using visual studio there is a new 'single page app' MVC website template which includes angular and MVC Web Api controllers. This works well because your MVC server-side code provides json endpoints for the angular client side code to call. Additionally you can use the MVC controllers to serve the basic html view or views for your single page ...


8

I've been a WPF/Silverlight programmer for years building huge applications, such as trading systems, on MVVM. For me, as the years have gone by, I've learned that strict MVVM eats time and costs money. By strict, I mean rules such as "no code behind". It's impossible in anything but the most basic form/database app, not to have code-behind. Your designer ...


8

I really like MVVM and I find its challenges motivating and see the many benefits, but... For application or games that require a lot of UI/interaction code to add a lot of custom behaviors while keeping perf up - it is often better to use a bit dirty MVVM - use it when it is useful or in more data centric as opposed to interaction centric areas of the code....


8

A bit of an outsider comment/answer, I'm not a .NET MVC programmer but have done a lot of PHP, Java, and AS3 programming and relatively recently switched to AngularJS as well. My general feeling is that the back end should just be RESTful and shouldn't touch the front-end really and the front-end should only depend on the back end for data. There are some ...


8

Laravel and AngularJS actually work quite well together; there's a good video on Laracasts about it and a few good articles online. In general you wouldn't want to use multiple MVC frameworks in one project as it increases bloat, as well as a lot of redundancy. Your average PHP MVC framework will include an ORM, Templating engine, router and so on - ...


8

Here is the design that I work with. I found it useful on two larger projects I built and haven't hit any road blocks so far. Folder Structure your-project/ apps/ global.html app1/ index.html app1.module.js app1.js parts/ foo.js foo.html ... app2/ libs lib1/ lib1.module.js ...


8

Yours is a common-enough problem that the solution is has a name: an anticorruption layer. This is a layer that translates between an external API with an undesirable structure and the desired internal structure of your app. The idea is to limit the "corruption" of the undesired structure to as small a part of your code as possible. The external API ...


8

If by "traditional" you mean every client hammering the server as often as they can then I can help at the architectural level. The appropriate design depends on where your server falls in this grid: Control \ Resources : Sufficient | Insufficient Customizable : SC | IC Untouchable : SU | IU SC : Make the server ...


7

If your application requires that you bind to excessive amounts of data in real time, then MVVM can actually get in the way because it's introducing abstractions that slow the process down and, assuming we are talking about WPF/Silverlight/WP7 right now, the binding engine is currently not that efficient; although enhancements are on the way. MVVM, as it ...


7

My preference is for defining a & attribute in the directive scope primarily because I view the scope: {} definition of a directive as its API. It's much easier to look at a scope attribute definition to see what information the directive needs to function properly than it is to scour link and controller functions for $emit'd events, inherited scope ...


7

We had the same choices to make. We decided to : make the whole build process not depend on visual studio. We chose use tools that are considered mainstream in angular development world. This way getting support by the community is easier. use visual studio extensions when available to enhance the experience when possible How : use grunt and karma. We ...


7

Single Page Apps (SPAs) aren't really intended to be used the way that you're suggesting with a really large application and multiple mini-SPAs within the main one. The biggest problem will be page load times as everything has to be loaded up front. One way to tackle this is using a navigation page that will take you to individual SPAs. The navigation ...


7

It depends on whether or not you're writing a lot of bare Javascript code to perform functions that are already well-served (or perhaps better served) by the libraries. In the specific case of jQuery, it is specifically designed to provide a library of useful functions in a cross-browser independent way. So if you're writing a lot of hackish code to get ...


6

JSON/HTTP is a really good decoupling mechanism, and I'll throw out a couple of suggestions that will make it even more loosely coupled. The rapid industry adoption of JSON/HTTP interfaces really speaks well about how people view the usefulness of that model. Enforce a MUST IGNORE rule. That is, when parsing the JSON (client or server), the app MUST ...


6

SPA is most beneficial if you are creating an application that does not fit the classical request/response pages model. There are a recent trend where regular websites are written as a SPA even when they fit just fine into the request/response cycle of the web, IMHO what they are doing are foolish endeavours. What the likes of these websites are doing is ...


Only top voted, non community-wiki answers of a minimum length are eligible