I\'ve a screen in below structure.
UserExperienceScreen
tab 1 -
It is not advisable to pollute the $rootScope
like this, instead you can either share a common servce data across your controllers or simply use one controller for all your tabs, such as the following:
[1] Share a common service data across your controllers:
DEMO
JAVASCRIPT
angular.module('plunker', ['ui.bootstrap'])
.service('Common', function() {
this.tabData = {};
})
.controller('SampleController', function($scope, Common) {
$scope.tabData = Common.tabData;
})
.controller("SampleTab2Controller", function($scope, Common) {
$scope.tabData = Common.tabData;
});
HTML
<tabset ng-init="steps={step1:true, step2:false}">
<tab heading="Step 1" active="steps.step1">
<div data-ng-controller="SampleController">
<form data-ng-submit="submitTab1()">
<label>Input Text</label>
<input type="text" ng-model="tabData.text" required >
<button type="submit">Next</button>
</form>
</div>
</tab>
<tab heading="Step 2" active="steps.step2">
<div data-ng-controller="SampleTab2Controller">
<form name="step2">
<p>Text from Tab1</p>
<input type="text" ng-model="tabData.text" >
</form>
</div>
</tab>
</tabset>
[2] Use one controller for all your tabs
DEMO
JAVASCRIPT
angular.module('plunker', ['ui.bootstrap'])
.controller('TabController', function($scope) {
});
HTML
<tabset ng-init="steps={step1:true, step2:false}"
ng-controller="TabController">
<tab heading="Step 1" active="steps.step1">
<div>
<form data-ng-submit="submitTab1()">
<label>Input Text</label>
<input type="text" ng-model="tabText" required >
<button type="submit">Next</button>
</form>
</div>
</tab>
<tab heading="Step 2" active="steps.step2">
<div>
<form name="step2">
<p>Text from Tab1</p>
<input type="text" ng-model="tabText" >
</form>
</div>
</tab>
</tabset>