Search for Programming, AngularJS, Rails, Testing ...

Rendering in Angular2

Get an idea of how Angular2 internal rendering system works

Angular2 is currently in beta with a stable release hopefully coming out sometime in the coming months. Lot's of new amazing stuff is being developed both inside and outside of the framework. New features such as a new version of NgAnimate, a pre-compilation build-step, and even Web Worker support are all coming to the framework. Another super cool feature that is in Angular2 is custom rendering. With the new design decisions that Angular2 has brought forth, the possibility of setting up a custom renderer to take on the UI responiblities is something that is possible.

Let's briefly dive into how the rendering architecture of Angular2 works.

Read More

Custom Cross-Browser CSS Properties

Cross-browser support for custom CSS properties is possible you know

If you've been developing websites for a while you may have wondered if there is anyway to set custom properties in your CSS code and have some piece of JavaScript code read and make use of the data. This isn't supported by browsers as of now, but if it where then imagine what we could do with our application? By having custom CSS properties, our JavaScript code could take over from where CSS code reaches a limitation. We could delegate all of the UI-related customization into our stylesheets and make use of media queries without having to have another set of customizations within our JavaScript code. Oh man, if only this was possible.

Well, using some clever CSS hackery and a custom build script, we can make use of custom CSS properties within all modern browsers. Let's explore how to make use of this ground-breaking new feature and see how it all works behind the scenes.

Read More

Taming Forms in AngularJS 1.3

Learn how to use the new form features in AngularJS 1.3

Forms in AngularJS 1.3 have been improved quite a bit from what they were back in 1.2 and 1.1. Lots of bugs for native HTML5 validators have been resolved and new features such as the validators pipeline and asynchronous validations have also been introduced. Packaged together with nested forms and the new ngMessages module, AngularJS 1.3 is more powerful than ever when it comes to developing forms.

Let's have a look at these amazing new features and craft together some amazing user input forms!

Read More

How to use ngMessages in AngularJS

ngMessages is a new feature in AngularJS 1.3 for rending error messages in forms

Forms in AngularJS are a delight to work with since they naturally work off of the basics of how forms work in HTML. The ngModel directive peacefully works with form controls and the state of a form can easily be examined using the name of the form and the name of each input control. But what about displaying error messages? Since there is no set way of displaying error messages in forms, there are many inconsistent ways to do this in AngularJS. While showing and hiding a message is easy using ngIf or ngSwitch, making use of multiple messages across and entire application is where things get messy. Do we really have to use ngIf over 20 times for a form just to show a handful of messages? How can we reuse a template of messages in other parts of the application? Are forms really this complicated?

The new ngMessages module introduced in AngularJS 1.3-beta.8 is designed to render error messages in a reusable and maintainable way. Instead of having to butcher up your template code by placing ngIf statements everywhere, ngMessages listens on the `model.$error` object and then decides which messages to display based on what is present in the template.

Interested in learning more? let's explore the ngMessages and ngMessage directives in detail.

Read More

Staggering Animations in AngularJS

Learn to use staggering to enhance your AngularJS animations

Most animation frameworks aim to do the same thing. Whether that be to offer JavaScript or CSS3 animations, a nice and easy to use API, or a quick and dirty integration procedure. Despite all that nice stuff, there is, however, one specific feature that is difficult to properly use and rare to come by ... Staggering Animations.

The idea is simple, but the implementation is difficult. Greensock is one, if not the only, animation framework that does this perfectly, but how do we get this to work with an AngularJS application? With the spectacular new features available in ngAnimate let's have a look to see how we can perform this crazy animation effect within our AngularJS app.

Read More

Advanced Testing and Debugging in AngularJS

Learn to test your AngularJS application like a Pro using the latest and greatest

AngularJS is becoming immensely popular and mainstream which means that there is a lot of AngularJS code out there that is being tested or is yet to be tested. And now that you're well on your way to test like a pro, thanks to the abundance of articles, tutorials, books and material out there on AngularJS testing & development, testing should be a mandatory process of your web development workflow.

Full-Spectrum testing with AngularJS & Karma taught us how to test certain areas of your AngularJS application, but how do we test efficiently? How do we debug a problem down the root cause? How do we skip tests, set breakpoints, and professionally mock-out our test components so that we can catch hidden bugs and unexpected scenarios? How far can and should we go with Unit & E2E testing? What else should we consider. Well lets take a deeper dive into testing in AngularJS and expand our minds by learning how to become a professional front-end tester.

Read More

Remastered Animation in AngularJS 1.2

Learn how to use the bigger and better animation features in AngularJS 1.2

AngularJS 1.2rc1 1.2 is out and this brings in a brand-new API for animations using ngAnimate. A lot has changed, but animations are better than ever. With 1.2, animations come full circle with new features such as support for ngClass, class expressions, and callbacks. Animations are also entirely class-based which means so long as a CSS class is present in your HTML code, then animations can be directly hooked into a working application.

This article will explain how to perform animations in AngularJS 1.2 with the new API setup. For earlier versions of AngularJS, please use 1.1.5 if you wish to stick to the older API of ngAnimate.

Read More

Enhanced Animation in AngularJS

Learn how to make even better animations in AngularJS 1.1.5

AngularJS Animations hit the web last month in version 1.1.4 of AngularJS. While being a advanced feature, animations in AngularJS were a bit too basic for what they were. Now, with version 1.1.5, animations are even easier to use and 1.1.5 comes packaged with more great features for you to play with. With support for CSS Keyframe animations, multiple property durations + delays and a whole lot of fixes. AngularJS animations are better than ever.

Want to learn how to make use of these new kick ass animation features with AngularJS? Shift your focus and follow along on another jam-packed yearofmoo article :)

Read More

Animation in AngularJS

Learn how to make use of the new animation hooks in AngularJS

AngularJS is an outstanding, all-inclusive and extensive framework that is phenomenal for crafting together full-blown JavaScript MVC apps with small amounts of code. But how do you stick in animations into your application? You could simply use CSS transitions combined with CSS classes, but that doesn't hook into the guts of your app. Or you could somehow tie in callbacks into your directives, but that's a maintenance nightmare and it slows down your app too much (plus it's hard to test).

Up until now, it was safe to say that native animations were not present in AngularJS. Well animation is here and yearofmoo is well prepared to hook you up. So lets take a look at how exactly make use of this great new feature with the world's best JavaScript MVC framework.

Read More

Full-Spectrum Testing with AngularJS and Karma

Learn how to fully test your AngularJS application with Karma

One of the major areas of AngularJS development which needs to be covered in better detail is how to test your application. But wait, how do you do that? How do you setup your test environment? How should you organize your code? How do you setup a runner and how to automate the process? The bigger question is how do you usually test your JavaScript code? Do you use a browser-independent JavaScript tester like NodeJS, V8 or Rhino? Do you use a hidden browser like PhantomJS or Headless Webkit? Or do you go all out and test out your application in a browser or multiple browsers? You may also be wondering what exactly to test in your application? What should my tests really look for? How should I write my specs? As you can see there are many questions to answer.

It doesn't take much time to realize that testing JavaScript is difficult and finicky. However, if you wish to get a robust understanding of how to properly test your JavaScript code within your AngularJS application, then continue and read along... :)

Read More