I am currently evaluating AngularJS as a potential MVC framework. I am wondering on what the "correct" way to implement the following scenario is -
Say I am designing an User detail page. It is broken down into different tabs like basic information tab(name, email...), user interests tab(drop downs like sports, music..), etc.
So the code looks like this:
<!-- main.html-->
<div ng-controller="UserController">
<div ng-switch on="renderPath">
<div ng-switch-when="basicInfo">
<div ng-include src="basicUrl"></div>
</div>
<div ng-switch-when="interests">
<div ng-include src="interestUrl"></div>
</div>
</div>
</div>
and interests.html looks like
<div>
<div class="dropdown">
<a class="dropdown-toggle" id="dLabel" role="button" data-toggle="dropdown" data-target="#" href="/page.html">
I like to play:
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<li ng-repeat="sport in sports">{{sport}}</li>
</ul>
<a class="dropdown-toggle" id="A1" role="button" data-toggle="dropdown" data-target="#" href="/page.html">
I like to listen to:
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<li ng-repeat="genre in genres">{{genre}}</li>
</ul>
</div>
</div>
So the question is, asides from the UserController, should I create a separate controller for the "basicInfo" and "interests" tabs? The reason why I may want to create InterestsController is because I don't necessary think
$scope.sports= ['baseball', 'bastketball'];
$scope.genres= ['pop', 'classical'];
should live in the UserController since only Interest.html cares about the different selections of interests. Also UserController may get real fat real quick since the page will have many other tabs.
But at the same time, in Angular's documentation - *"In Angular, a model is any data that is reachable as a property of an angular Scope object"*, I feel like if I do then have an InterestsController, etc, its model is rather arbitrary since it is just containing the information needed for that tab only.
So what's the best practice? I hope I explain myself clearly. Thank you.