Hi guys,
I’m exploring angular right now and like it a lot. But I’m not sure what the best way to write reusable components is. Here my question:
I want to create reusable component that:
--------------------------------------------------------------------------
| Dashboard
component
|
|------------------------------ ------------------------------ |
||
Widget(a) | |Widget(b) ||
|----------------------------- --------------------------------|
|------------------------------ ------------------------------ |
||
Widget(c) | |Widget(d) ||
|----------------------------- --------------------------------|
--------------------------------------------------------------------------
How would you achieve this?
My current thoughts:
Directives
Plus: Good reuse and I can easily access attributes
Minus: more the kind of a small component, how would I use Controllers or Services to call the backend?
Controllers:
Plus: Good access to services (DI), could be parameterized with ng-init
Minus: It’s
only the code part. How would I bundle the view? Use ng-include?
Beside of that I’m not sure how multiple controllers and nesting them would result in some problems.
Kind regards
Tom