I want to make a navigation bar in my web, so, in the index I want to put the section where the user is located.
The problem I have is that I do not know how to pass the variable to the MasterController from the Controller of each view, so that changing the section is automatically changed in the index.
I'll attach the link to the example I'm using.
Master Controller
angular.module('RDash')
.controller('MasterCtrl', ['$scope', '$cookieStore', MasterCtrl]);
function MasterCtrl($scope, $cookieStore) {
/**
* Sidebar Toggle & Cookie Control
*/
var mobileView = 992;
$scope.getWidth = function() {
return window.innerWidth;
};
$scope.$watch($scope.getWidth, function(newValue, oldValue) {
if (newValue >= mobileView) {
if (angular.isDefined($cookieStore.get('toggle'))) {
$scope.toggle = ! $cookieStore.get('toggle') ? false : true;
} else {
$scope.toggle = true;
}
} else {
$scope.toggle = false;
}
});
$scope.toggleSidebar = function() {
$scope.toggle = !$scope.toggle;
$cookieStore.put('toggle', $scope.toggle);
};
window.onresize = function() {
$scope.$apply();
};
}
Controller
/**
* Alerts Controller
*/
angular
.module('RDash')
.controller('AlertsCtrl', ['$scope', AlertsCtrl]);
function AlertsCtrl($scope) {
$scope.alerts = [{
type: 'success',
msg: 'Thanks for visiting! Feel free to create pull requests to improve the dashboard!'
}, {
type: 'danger',
msg: 'Found a bug? Create an issue with as many details as you can.'
}];
$scope.addAlert = function() {
$scope.alerts.push({
msg: 'Another alert!'
});
};
$scope.closeAlert = function(index) {
$scope.alerts.splice(index, 1);
};
}
The thing would be that the master modifies the index, it is the only one, it would have to know how to pass a parameter from the controller with the section to which each controller corresponds.
Thank you!