2

For this specific project, my team and I are thinking of leveraging the power of AngularJS directives and use them to build custom elements specific to our project, and use them like they were real HTML components.

For instance...

Say we have this table where each row is composed with a bunch of information that we get from a request, each row will be repeated with ng-repeat. Inside each row we will have multiple custom buttons with the same custom behavior. This button will also be used across different modules/pages on the website and not only on this specific table.

Our first thought was to use 2 directives, one for the table row and one for the button. The idea is that these are custom components/elements with custom attributes to define the custom behavior of the element. This would allow us to have a really nice modular application where each component is developed and unit-tested individually. Our HTML would also be easy to ready and understand.

Does this sound good?

Now, what about performance issues? Could we encounter big issues with this approach if, say we have a table with 100 of those rows and 5 of those buttons per row. Could this be big a problem if those rows/buttons had a couple of bindings to update information each X seconds?

rfgamaral
  • 16,546
  • 57
  • 163
  • 275
  • My 2 cents, my current app has a normal which contains a directive for each day of a month, for a list of employees. At the moment it shows about 70 employees (no filtering yet). So about 70 * 30 (2100) directives shown at the minimum. This takes about 3-4 seconds to render. (Back-end returns the data in the desired format, so no processing anymore, it seems to take that long before it can show everything)
    – Busata Mar 18 '14 at 19:14
  • 1
    Directives doesn't add too much overhead, bad code does. And there is always a couple of ways to improve the performance on good code. – Jesus Rodriguez Mar 18 '14 at 19:19
  • It's more about the weight of the action your directive takes. – Fresheyeball Mar 18 '14 at 19:53

1 Answers1

0

The father of Angular Misko Hevery has this to say about performance and data-binding:

How does data binding work in AngularJS?

But in short like he says as long as you dont have more than 2000 data-bound items per page performance wont be an issue...

Community
  • 1
  • 1
Sten Muchow
  • 6,623
  • 4
  • 36
  • 46