Angular Tips

Join us in our way to learning Angular.js

Transclusion and Scopes

| Comments

The problem

There is a common misconception that I see when I am doing Angular support. My goal here is to address it.

Let’s imagine I have this simple controller and directive:

Introduction to Unit Test: Spies

| Comments

Before we deep more into Angular lands, I want to talk about spies. No, no that kind of spies.

When you are doing unit testing, you don’t want to leave your SUT (subject under test) domain. If you’re testing a controller in Angular and it injects 3 services, you don’t care about those services, you only want to test that controller but also make sure it uses the services as intended.

Introduction to Unit Test: Introduction

| Comments

Let’s talk about unit testing our applications.

What is unit testing and why should I care?

Unit tests are a bunch of Javascript files that we create to make sure that every part of our application works as it is expected to work. That means that we need to write hundred of lines of code to assert that our code does what is supposed to do.

Isn’t that a waste of time? The boss is always telling us that we need to be faster and hundred of lines doesn’t sound like fast. Au contraire, that bunch of code will save us HOURS. Don’t believe me? I have proofs.

Tip: Computed Properties With Javascript Properties

| Comments

First, I apologize for not updating the blog as much as expected. I am kinda busy with other stuff and I am writing an Angular book. I want to write more so I am going to find some ideas that won’t be covered in my book. Well, let’s get started.

There is a question I see a lot about Angular: Does it support computed properties? Well, there is no direct support in the framework like with Ember, but you can certainly create computed properties. Let’s see an example, the typical example:

Experiment: Decorating Directives

| Comments

DISCLAIMER: This is an experiment, it is not something officially supported and because of that, this is not meant for beginners. Use it at your own risk and take notice that a bad use of it can break the Internet.

Jokes aside, this could be useful in a bunch of use cases. It is up to you to decide.

Ever had a third party directive where you wished it had any extra behavior you wanted? I did.

My Workflow With Lineman

| Comments

So, we decided to create a new Angular.js application. What should we do? Integrate our application into our backend? Pick an existing seed and extend it?

Here I want to explain what is my workflow and why I go through that route.

Understanding Service Types

| Comments

Angular comes with different types of services. Each one with its own use cases.

Something important that you have to keep in mind is that the services are always singleton, it doesn’t matter which type you use. This is the desired behavior.

NOTE: A singleton is a design pattern that restricts the instantiation of a class to just one object. Every place where we inject our service, will use the same instance.

Let’s start with my own opinion about services.