Closed
Description
When I have two states nested. Lets call them about and about.stateone. Now, in both I have controller which has function called Change. When I go to the child scope, function works, but now when I go back to the parent, the function does not work.
Code:
$stateProvider
.state('about', {
url: '/about',
templateUrl: '/partials/about.html',
controller: ['$scope', function ($scope) {
$scope.test = '1';
$scope.Change = function () {
console.log('cahgne 1');
$scope.test = 'change 1111';
};
}]
})
.state('about.stateone', {
url: '/one',
template: '<div>' +
'<p>test: {{test}}</p>' +
'<button ng-click="Change()">Change 2</button>' +
'</div>',
controller : ['$scope', function ($scope) {
console.log('in ctrl 2');
$scope.test = '2';
$scope.Change = function () {
console.log('cahgne 2');
$scope.test = 'change 2222';
};
}]
})
And the HTML of about state:
<ui-view>
<p>Test: {{test}}</p>
<button ng-click='Change()'>Change</button>
</ui-view>