Currently exploring angularJS for the development of a simple side menu. I have a choice between two directive designs, and I'm facing a dilemma in picking the better one:
Option 1
The HTML structure:
<sidebar title="Sidebar Heading">
<sidebar-element name="Heading">Description</sidebar-element>
...
</sidebar>
Option 2
The HTML setup:
<sidebar>Sidebar Heading</sidebar>
Moreover, the data is being fetched directly from the controller:
$scope.sidebarElements=[{name:'Head 1', description:'Description 1', isActive:true}];
Keep in mind that the JSON data is originating from the server.
If Option 2 is chosen, passing the data to the controller can be done efficiently.
On the other hand, with Option 1, utilizing
<sidebar-element ng-repeat='element in elements' ...>
would be essential, followed by sending the data accordingly. Even though Option 1 seems to possess a more structured approach, the necessity for an extra layer of abstraction raises doubts on its relevance.
Which option should I lean towards, and what makes it the preferable choice?
I am relatively new to AngularJS and aiming to grasp the concepts needed to think effectively within this framework.