When defining routes, I have the following code:
$stateProvider
.state('app', {
url: '',
abstract: true,
views: {
'login' : { templateUrl: 'view/login.html', controller: 'authentication' },
'navbar-top' : { templateUrl: 'view/navbar-top.html', controller: 'authentication' },
'recover' : { templateUrl: 'view/recover.html', controller: 'authentication' },
'register' : { templateUrl: 'view/register.html', controller: 'authentication' }
}
})
...
I have different views with the same controller.
In the 'navbar-top.html' view I have the 'login' and 'Register' buttons.
When you click on "login" the view "login" should be changed, but nothing happens because the variables are not changed.
From what I noticed, despite having the same controller, angular create a new instance for each view.
How to reuse and even controller for different views?