خرید بک لینک

Vote count: 0

I'm using $stateProvider with AngularJS and I'm wondering if there's any way to get the abstract, or parent, controller from a child state. Before you throw $parent out there, it doesn't seem to work as I thought it would.

Example:

$stateProvider.state('page',
{
    url: '/page',
    abstract: true,
    cache: false,
    templateUrl: 'navigation.html',
    controller: 'navigationController'       
});

$stateProvider.state('page.login',
{
    url: '/login',
    templateUrl: '...',
    views: 
    {
        'login':
        {
            templateUrl: 'login.html',
            controller: 'loginController'
        }
   }     
});

So, the question is, how would I modify a value in navigationController from loginController.

EX:

var navigationController = function($scope) {
    $scope.showNavigation = true;
}

var loginController = function($scope) {
    $scope.onClicked = function() {
        // navigationController::$scope.showNavigation = false
    }
}

I've tried using $scope.$parent.showNavigation but that doesn't modify the value. Printing $scope.$parent yields an unreadable nested object of the current scope.

asked 34 secs ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 16 تير 1395 ساعت: 12:17

صفحه بندی