background preloader

Jmcunningham/AngularJS-Learning

Jmcunningham/AngularJS-Learning

JavaScript Promises No I am not talking the promise that JavaScript will fix everything if you use it. I don't even believe that ;) I am talking about the concept of a promise object that several JavaScript libraries use (including AngularJS, jQuery, Dojo and WinJS). A promise is a pattern for handling asynchronous operations. In this example you can see the jQuery uses the success property of the settings object to specify the callback. The promise pattern sets out to simplify this process. What is interesting here, is that the object that ajax returns is the xhr object which implements the promise pattern so we can call then as seen here. Because many libraries are starting to take on the promise pattern, handling asynchronous operations should be easier no matter what code you're writing (e.g. One important key to the pattern is that the then function can accept two functions. Let's see how using a promise looks. You can play with these examples in JSFiddle and see what you can make happen.

timjacobi/angular-education Promise-ы в AngularJS Одной из ключевых составляющих практически любого веб-приложения является взаимодействие с сервером. В больших приложениях это далеко не один запрос. При этом запросы часто необходимо объединять для последовательного или параллельного выполнения, а часто сочетать и то и другое. Кроме того, большие приложения обычно имеют многослойную архитектуру — обертка над RESTFul API => бизнес-сущности => более комплексная бизнес-логика (разбиение условно для примера). И на каждом слое необходимо принять данные в одном формате и передать на следующий слой уже в другом. Вот со всеми этими задачами могут помочь справиться Promise-ы. За подробностями добро пожаловать под кат. Promise-ы предоставляют интерфейс для взаимодействия с объектами, содержащими результат выполнения некоторой операции, время окончания которой неизвестно. Кроме того, promise-ы можно объединять как для последовательного, так и для параллельного исполнения. Итак, что из себя представляет promise? Что в AngularJS вернет вам promise?

Three.js and Babylon.js: a Comparison of WebGL Frameworks Today’s web browsers have come a long way since the days of Sir Tim Berners-Lee and his Nexus software. Thanks to fantastic JavaScript APIs like WebGL, modern browsers are fully capable of rendering advanced 2D and 3D graphics without help from third-party plugins. By leveraging the horsepower of dedicated graphics processors, WebGL gives our web pages access to dynamic shading and realistic physics. As you might have guessed, such powerful APIs typically come with a drawback. The humble origins of 3D frameworks The ever popular Three.js along with the newer Babylon.js offer web developers an abstract foundation for crafting feature rich WebGL creations ranging from animated logos to fully interactive 3D games. Three.js got its start back in April of 2009 and was originally written in ActionScript before being translated to JavaScript. Babylon.js, being the relative newcomer, broke onto the scene in the summer of 2013. A subtle difference in design Three.js: Babylon.js:

AngularJS and scope.$apply — Jim Hoskins If you’ve written a non-trivial amount of code in AngularJS, you may have come across the $scope.$apply() method. On the surface, it may seem like just a method you call to get your bindings to update. To really understand when to use $apply, it’s good to know exactly why we need to use it, so let’s dive in! JavaScript is Turn Based The JavaScript code we write doesn’t all run in one go, instead it executes in turns. Instead, whenever there is a task that takes some amount of time, such as an Ajax request, waiting for a click event, or setting a timeout, we set up a callback function and finish our current turn. Let’s look at an example JavaScript file: var button = document.getElementById('clickMe'); function buttonClicked () { alert('the button was clicked'); } button.addEventListener('click', buttonClicked); function timerComplete () { alert('timer complete'); } setTimeout(timerComplete, 2000); When the JavaScript code is loaded, that is a single turn. How do we update bindings? $scope.

Journey Through The JavaScript MVC Jungle When writing a Web application from scratch, it’s easy to feel like we can get by simply by relying on a DOM1 manipulation library (like jQuery412) and a handful of utility plugins. The problem with this is that it doesn’t take long to get lost in a nested pile of jQuery callbacks and DOM elements without any real structure in place for our applications. In short, we’re stuck with spaghetti code3. What Is MVC, Or Rather MV*? These modern frameworks provide developers an easy path to organizing their code using variations of a pattern known as MVC4 (Model-View-Controller). Models represent the domain-specific knowledge and data in an application. JavaScript ‘MVC’ frameworks that can help us structure our code don’t always strictly follow the above pattern. For this reason we refer to such frameworks as following the MV* pattern, that is, you’re likely to have a View and a Model, but more likely to have something else also included. When Do You Need A JavaScript MV* Framework? Dojo Link

Index Loading... A great way to get introduced to AngularJS is to work through this tutorial, which walks you through the construction of an AngularJS web app. The app you will build is a catalog that displays a list of Android devices, lets you filter the list to see only devices that interest you, and then view details for any device. Follow the tutorial to see how AngularJS makes browsers smarter — without the use of native extensions or plug-ins: See examples of how to use client-side data binding to build dynamic views of data that change immediately in response to user actions.See how AngularJS keeps your views in sync with your data without the need for DOM manipulation.Learn a better, easier way to test your web apps, with Karma and Protractor.Learn how to use dependency injection and services to make common web tasks, such as getting data into your app, easier. When you finish the tutorial you will be able to: Install Git You can download and install Git from

Choosing a JavaScript MVC FrameworkFunny Ant So you love the way single-page apps like Gmail and Trello feel, but aren’t sure where to start. Maybe your JavaScript code has become disorganized enough that you are convinced to try one of the numerous JavaScript MVC libraries/frameworks on your next project but aren’t sure which one to choose. I’m writing a book on single-page apps so I’ve pretty much “read the internet” on the topic. I’ll attempt to provide some not so obvious insights to help you make your decision. Introduction The frameworks discussed are the ones with the most traction at present: AngularJS, Backbone, Ember, and Knockout. Each project is examined from several different perspectives including community, leadership, maturity, size, dependencies, interoperability, inspiration, philosophy, and features. Community A good indicator of the health of any open source project is its community. You wouldn’t want to make your framework decision on this data alone but it certainly gives you a sense of which frameworks are: Size

Related: