I would like to create an AngularJS app in which I woud have a page containing multiple tabs. Since each tab would have a very specific business logic, I am wondering what would be the best way to achieve such a thing, knowing that I want to be able to pass through data from tab to tab. The user would have to follow a specific workflow, starting on the first tab, clicking on a button and landing on the second tab, able to see and use data he generated from the first tab, and so on.
I have come across this articles : Top 18 Most Common AngularJS Developer Mistakes which talks about controllerAs
attribute. Would it be something I could use to have let's say:
- a route provider with a main controller
- a main view including each of my tabs' view
- a view per tab with an associated controller
- use
controllerAs
to be able to pass given shared data from a controller to another
UPDATE
Apparently it is clear that it cannot work if I do something like that:
Javascript:
angular.module('myApp').controller('FirstController', function(){
this.myVar = "I am from FirstController";
});
angular.module('myApp').controller('SecondController', function(){
this.myVar = "I am from SecondController";
});
HTML :
<div ng-controller="FirstController as FC">
{{FC.myVar}}
{{SC.myVar}}
</div>
<div ng-controller="SecondController as SC">
{{FC.myVar}}
{{SC.myVar}}
</div>
How could I make something like this nice and working? Or should I really have shared variables amongst the controllers provided from a MainController, wrapping these two?
Thank you for your helps.
Kind regards,