Angular2 Databinding is Fast!

I’ve been working with the Angular2 alpha ever since ng-conf 2015, and it has been pretty awesome to see how the framework is shaping up. I’ll be the first to admit that the bleeding edge tax is high, but it has been worth it to see just how powerful the next version of Angular is going to be.

The databinding system in Angular2 is so much better than the previous version that it is hard to talk about it in the abstract. I could go into a bunch of boring technical details, but I think seeing is believing.

The Setup

I wanted to see just how fast the new data binding system was, so I thought… why not animate a bunch of elements using nothing but databinding.

<table class="table table-striped table-condensed table-floating">
    <tbody>
        <tr *ng-for="#row of statusBoard">
            <td *ng-for="#col of row" [style.top]="col.top" [style.left]="col.left">&nbsp;</td>
        </tr>
    </tbody>
</table>

If you aren’t familiar with the syntax, don’t worry, basically I am using a nested repeater to create a bunch of rows and columns, and then data binding their position on the page.

The Code

GitHub Repo

Under the hood, I am using requestAnimationFrame to modify their positions as quickly as I possibly can. The code is long and boring, but the relevant bits are here:

updateBoard(elapsedMilliseconds) {
    var elapsedSeconds = new TimeSpan(elapsedMilliseconds - this._lastStep).totalSeconds;
    this._lastStep = elapsedMilliseconds;

    for (var row = 0; row < dimensions.rows; row++) {
        for (var col = 0; col < dimensions.cols; col++) {
            this.statusBoard[row][col].move(elapsedSeconds, this._config.bounds);
        }
    }

    requestAnimationFrame(this.updateBoard.bind(this));
}

The Result?

Well… see for yourself.

Rachel Snowbeck

View Comments

    • @larsjeppesen:disqus - I am enjoying working with it so far. It certainly has some rough points, but that is to be expected in early alpha. The team seems to be working hard to take into account usability and is making efforts to smooth over those rough spots.
      The bones are good though.

  • @larsjeppesen:disqus - I am enjoying working with it so far. It certainly has some rough points, but that is to be expected in early alpha. The team seems to be working hard to take into account usability and is making efforts to smooth over those rough spots.
    The bones are good though.

Recent Posts

8-Step AWS to Microsoft Azure Migration Strategy

Microsoft Azure and Amazon Web Services (AWS) are two of the most popular cloud platforms.…

11 hours ago

How to Navigate Azure Governance

 Cloud management is difficult to do manually, especially if you work with multiple cloud…

1 week ago

Why Azure’s Scalability is Your Key to Business Growth & Efficiency

Azure’s scalable infrastructure is often cited as one of the primary reasons why it's the…

3 weeks ago

Unlocking the Power of AI in your Software Development Life Cycle (SDLC)

https://www.youtube.com/watch?v=wDzCN0d8SeA Watch our "Unlocking the Power of AI in your Software Development Life Cycle (SDLC)"…

1 month ago

The Role of FinOps in Accelerating Business Innovation

FinOps is a strategic approach to managing cloud costs. It combines financial management best practices…

1 month ago

Azure Kubernetes Security Best Practices

Using Kubernetes with Azure combines the power of Kubernetes container orchestration and the cloud capabilities…

2 months ago