Client side MVC plus media responsive UI - angularjs

I m still new to client side MVC and at this point exploring my options.
Angular.js, Ember.js both are highly recommended frameworks, backbone.js is a library but most of the implementation user has to do.
Need a opinion from someone who has been working in client side MVC, as to how should one decide which one to go for?
Plus I need the UI to be media responsive, for which twitter Bootstrap looks ideal.
Is it possible to use one of these framework along with Twitter Bootstrap? In which framework is it easier to integrate Bootstrap?
Thanks.

AngularJs and Bootstrap are the two which I would start with.
AngularJS is opinionated, this means it will help you structure your code well. If you just want binding then don't forget knockoutjs. This is in the mvc package by default in VS.
Bootstrap is just html and css markup so should work with everything.
If you start a MVC5 project now in VS2013 you will by standard have bootstrap.
Many people will have different opinions on this so you could wait for an answer for a long time.

I understand your confusion when it comes to selecting the right JavaScript framework. There are many deciding factors that you must evaluate before dedicating your time and money. I noticed that you mentioned a MVC in your questions title. The first thing that you will want to understand is exactly which MV* architecture that you want to have for your app and why. Once you have that nailed down then selecting the framework will be much easier since you will have eliminated a few of the frameworks. The four architectures are MVC, MVVM, MVP and MV*. Another major factor that you will want to look at is the binding mechanism used for the framework. Some frameworks only allow one way bindings while others support 2-way bindings.
To answer your question, based on what you have explained, I would say that Ember is going to be your best bet. Ember will work with Bootstrap
http://ember-addons.github.io/bootstrap-for-ember/dist/
If your still researching the facts then you will really want to check out this helpful link to a page that goes over the pros and cons of the most popular JS frameworks.
Check it out here: http://coding.smashingmagazine.com/2012/07/27/journey-through-the-javascript-mvc-jungle/

Related

Convert Silverlight APP to HTML5 SPA – tools and technologies

My team is working on a strategy to convert our cloud based Silverlight app to HTML5 app. Although we have been working on formulating a strategy to find best possible set of tools, technologies, and methodologies to convert our App to HTML, I am asking this question here to get some feedback from the large community at SO and to learn from experiences of the people who may have done similar things in recent past.
My question has a few parts.
Our app is written in Silverlight and uses WCF RIA services. Most importantly, we rely a lot on MVVM and we wish not to rewrite that logic again hence to reuse as much code as possible. What would be, in your opinion, the best possible combination of tools and technologies for us to use?
In order to make SPA, we would like to use some of the “cool” new frameworks out there but we really want to minimize our work (due to hard deadlines) and be able to thoroughly test our app easily and quickly (hence the code reuse). Is SPA even a good option or should we go for traditional MVC app? Keeping in mind that there are more than 200+ views in our app.
If we chose to go the SPA route, which framework is best suited in terms of life span. We have to move away from Silverlight because it is going to die soon. We don't want to be in the same situation again in near future.
Moving an existing Silverlight app to and HTML5 web app is the perfect project for AngularJS. Angular has it's own similar MV* design pattern, but you will not be "reusing" code from your existing silverlight apps. The main ideas and abstractions may be similar, but just the nature of how html and js work together, and especially how they work in angular, you have to do it the angular way.
Also, Angular is somewhat of an engineering approach to web development. It is not a learn-it-in-a-weekend piece of cake framework to master. There's a lot that goes into it. There's noob ways to do things in Angular, somewhat noob-ish ways to do the same things, and then the so-called "right" way of doing it so you may find yourself learning some ways of doing things only to have them replaced with "better ways".
If you want to "minimize your work" then Angular might not be the best choice, but if you want your HTML5 app to be really awesome then any framework you with will require some studying in addition to getting used to the inherent quirks of Javascript.
Angular 2 is hot and just launched a Beta release, but I'm still happily using AngularJS 1.4 for all production apps.

Replacing angular with standard web technologies

I'm working on a project which has the luxury of using ECMA 6 on the latest browsers for a product that will be shipped in 1.5 years. So we thought why not use Web Components now that Angular 2 isn't available (which is going to be ECMA 6). And while we are at it, can we replace Angular altogether without having to go back to stone age?
How to replace Angular?
There's this site called youmightnotneedjquery.com which is basically about how modern browsers actually have most of the stuff that jQuery was traditionally used for. I'm interested to see something like that for Angular.
We mainly use four Angular features. What are my options for replacing them?
Angular Directives --> Web Components
Angular Modules --> ECMA 6 Modules (not exactly the same thing)
Angular Routes --> ???
Angular 2-way databinding --> ???
PS. We don't want to replace Angular with something similar like Backbone or Ember. We want to replace it with standard web technologies but if we have to use small tools to fill the gap, we'll consider it.
I've been researching in the past 3 weeks and turns out many people are thinking about an alternative after Angular took a drastic change path. Fortunately the upcomming W3C Web Components standard actually has all we need and it works right now with polyfills from the Polymer project. So to answer the question:
Angular Directives --> Web Components use the polyfill until all browsers support it.
Angular Modules --> ECMA 6 Modules part of the problem is solved with HTML imports. But you can also use Traceur until the browsers support it.
Angular Routes --> There's a component for that™ use <app-router>.
Angular 2-way databinding --> Polymer adds a "magic" layer on top of the plain standard web components. This includes many features including data-binding.
+Plus More
If you're wondering about the build process for concatenating files in order to reduce the number of HTTP requests, take a look at Addy Osmani's post about Vulcanize. Spoiler: you may not need it with the upcoming HTTP 2 optimizations.
Many Angular projects use Twitter Bootstrap for the layout. Polymer can do that plus it plays nicely with Google's Paper elements (totally optional but superbly awesome).
If you want to make yourself familiar with web components in general, here is a bunch of nice articles: http://webcomponents.org/articles/
And here is a wealth of web components: http://customelements.io/ I don't know if it's going to be a new NPM, but the list components is pretty impressive and growing.
It's relatively complicated to expose an API for an Angular component. People have come up with all sorts of methods from link function to emitting events. In Web Components, however, it's really easy to make your component interact with the world outside and indeed the API and events you expose aren't much different from standard HTML tags like <audio>.
Just like Angular, you can use Polymer with Dart as well.
Conclusion
Overall, I don't see any reason to use Angular except if:
You have a huge source code investment in angular and don't want to port everything to standard web. (Angular 2.0 will deprecate your code anyway, so you're stuck with Angular 1.*)
Your team is too lazy to learn a new technology (in that case web might not be the right platform for this attitude anyway).
Angular was good for what it was doing and had its own Hype cycle. Web components solve many of the issues Angular was trying to address. Probably Angular had a role as a proof of concept for the Web components. But now it's time to move on. Web is reinventing itself everyday and it's inevitable to moves someone's cheese.
I'm not saying that Polymer is the ultimate answer to everything. At best it's another Angular which will render useless in a couple of years, but now it's a good time to learn and use it. The W3C standards don't die easily though, and Polymer tends to be much closer to them.
There's an element for that™ is the new There's an app for that™
TLDR: seriously consider writing an almost Angular 2.0-compatable Angular 1.3 app before rolling your own framework
It seems as if you've identified that Angular does a lot of things the right way and that's why you're attempting to replicate it, so basically you're going to roll your own by combining a hodgepodge of libraries. Unless you have an enormous investment of Engineering hours, the framework you build will likely be:
Lightly documented
A cross-browser maintenance nightmare and (worst of all)
Difficult for new hires to learn
If there wasn't a framework out there that did what you want to do already, I think rolling your own makes sense, but by trying to recreate Angular you're:
Taking on a lot of Engineering work that has already been done by a dedicated team, that could have been spent on building product
Made it MUCH more difficult to onboard new employees because you have to:
Find candidates that are willing to use a home-grown framework instead of growing their skills at an open source framework they could use elsewhere
Train these employees to use your framework (and good luck unless your documentation is mature)
I know your question asks how to replace Angular, but I've seen too many companies go the route of rolling their own and paying for it down the road. Again, if your budget includes a ton of core resources to build out (and document, and maintain) the framework and you don't think there is any chance corners will get cut when push comes to shove later if timelines get tight, then rolling your own might make sense. However, I think you should seriously consider reading up on how to write Angular 1.3 apps so that they're easy to port to Angular 2.0 and go the Angular route. Just look at the size of the community you're missing out on:
http://www.airpair.com/js/javascript-framework-comparison

Pros and cons of using AngularJS + jQuery Mobile in one project

We're about to start a project using mentioned libraries. We have already used jQM in another project, but coupled with Backbone. Now we're thinking about using AngularJS with jQM. Do you think it's a good idea? And if not, why?
To elaborate, the question is whether it is advisable/recommended/easy/beneficial to use these libraries together, or maybe there is something that should prevent us from using them both in one project. We don't want to spend half of project's time on making them work together just on principle.
AngularJS and JQM do different things. AngularJS is MVC + Lot More. JQM on the other hand is for direct UI manipulation (lower level than Angular). The good news is AngularJS is flexible and will let you work with any other Javascript framework including JQM. The recommended way of using them together is use the adapter as mentioned above or create your own reusable directives that will add "JQM nature" to your views. For e.g. you can create a directive that will convert a standard UL to a fancier JQM list. The good thing about doing this in directives and not within your view is that your UI code is separated in separate modules and not intermingled with business logic.

Is it possible to use ExtJS components in AngularJS?

I'm really enjoying learning to use AngularJS. Now I'm looking for components I can use with it. I've been looking at Angular-UI components but I'd like to know if it's possible to use the nice, supercharged components in ExtJS. Does anyone have experience with this? Any hints or tips or Angular directive libraries?
The company I work for is making a similar move. We currently rely heavily on an older version (3.x) of ExtJS, and the effort to upgrade to the current (5.0) version is at least equal to the effort required to move to angular.
To answer the question (to the best of my limited knowledge):
They can exist together in the same JS application.
Can you use UI elements of ExtJs with Angular?
You can put angular in control of markup via HTML templates in Ext.
Is this a wise idea?
Probably not.
Why would I consider doing this?
I need absolute control over the markup and don't care about possible page load issues
I need to serialize or de-serialize in some special way that Ext doesn't innately provide
I need to do something special like pub/sub (still totally possible with Ext)
In our case, it is a proof of concept for a few modals. If I am biased, I am biased in the direction of ExtJs (which is a huge statement given my background). The more exposure I have to ExtJS, the more I personally like it. I've used several frameworks in the past like Ember, Backbone, KnockoutJs and AngularJs and they are excellent tools that are reaching a level of maturity that makes them excellent choices. That said, they don't follow the same development model/pattern that ExtJs does, and I don't think a direct compare is fair to either side.
It would be almost like comparing Ext to Node (silly, I know).
If your project requires some special functionality that you don't believe is possible in Ext, you are probably like me and have limited experience with it. If you have a lot of experience with Ext, and want to try what we are trying, I say go for it. The single downfall of Ext is the size of the built package that is delivered. Another small framework isn't going to help that, but it also isn't going to cause more pain.
In the end, for me, I just love JS and expanding my knowledge of how things work now and in the future.
For the post above asking about the lack of traction for Ext: the answer is simple... it's not free, and thus not an option for many of us who aren't writing commercial software that fits well with the license.
In our AngularJS app at work, we have integrated a 3rd party ExtJS app with it, not for its UI components though. We open certain popups of that app based on user input and when the user commits data in the popup, we respond to ExtJs events to refresh our app. AngularJS is flexible enough to integrate with any other Javascript code/libraries as long as the library has public events to respond to. I would recommend going through the Directive and scope documentation on how to effectively create directives and respond to scope events.
Personally I do not feel ExtJS and AngularJS would be needed together, unless you are forced to use it like me. There is http://angular-ui.github.io/ that brings in a lot to the table. Again any given JQuery plugin can be integrated using directives, filters etc in AngularJS. So you may want to investigate into that before trying to bother with ExtJS.
Why do you need AngularJS anyway if you have ExtJS? I agree learning Ext can be somewhat difficult though once you've bitten through it there is nothing better at the moment. The only disadvantage is the heavier footprint but who cares? It's not like it's causing any problems... We use nothing but ExtJS at work and the progress in our apps is amazing. It integrates seamlessly with Spring MVC. We don't need to hack in HTML directly which I consider more of an advantage than a disadvantage: no more writing tags, no more open/close tag issues, you can still use css and Ext handles any browser incompatibilities so what else do you need more?? Angular is just the new kid on the block but in total it can not (yet) compete with ExtJS. It doesn't even com close. Just my 2$.
Sencha is planning to add support in the framework. Please find the link at the bottom for reference:
At SenchaCon in Las Vegas on November 7-9 2016, Sencha will be introducing the ability to use Ext JS components, layouts, and themes within an Angular 2 application, which we are currently calling the Ext JS Bridge to Angular 2 (also known as ‘The Bridge’).
https://www.sencha.com/blog/first-look-ext-js-bridge-to-angular-2/

Backbone.js Single Page Architecture

Simple questions, am I correct with this approach.
I have a page with left, centre and right areas (divs).
Each area has its own Backbone object, MVC/R
Each area has its default HTML via a default JQuery template.
Each Backbone object communicates Restfully to Asp.Net.MVC via JQuery.
Depending on the JSON payload back from its MVC Action(s) an area can switch its HTML via a JQuery template.
I got some code from the ‘net that does JavaScript EventAggregation communications between the Backbone objects in a similar way to Prism for WPF/Silverlight.
Do points 1 to 6 seem generally ok?
Could I use some sort of "pure" JavaScript eventing to replace point 6, if so how would I go about this?
As you can guess, I’m coming into this from a WPF/Silverlight background
Thanks in advance
Your list is good, and is a similar to how a lot of people are building Backbone apps these days. I would recommend against using jQuery templates, though. They are not supported right now, as the jQuery UI team is working on a road map to completely re-write them in to the jQueryUI project.
As for native JavaScript events - no. Stick with an event aggregator implementation that you are comfortable with. There isn't anything native in JavaScript.
You might also find my Backbone.Marionette project to be helpful and familiar. http://github.com/derickbailey/backbone.marionette
I also come from a .NET background, building composite applications (mostly in WinForms, but a little WPF). I've taken all of the core patterns that I used in building Winforms/WPF apps and built them in to Marionette. It removes a lot of the boilerplate code that I would normally write, and borrows ideas from Prism and other composite application frameworks.

Resources