I'm trying to access a scope variable defined in the app controller so i can update on a click event from Directive i've created, but it doesn't seem to be able to access the global scope from its isolated scope.
the scope variable is defined (currentTitle):
app.controller('news', function($scope, $http, $timeout) {
$scope.promise = $timeout(function() { //This is here just to mock the asynchronous loading of the data
$scope.articles = [{
title: 'Article 1',
content: 'It works!'
}, {
title: 'Article 2',
content: 'It still works'
}]
}, 3000);
$scope.currentTitle = "my - title";
$scope.showDetails = false;
});
and the scope defined in the directive is:
scope: {
//bind the showDetails into the scope so it can be seen by all of the accordion elements
promise: '&?',
currentTitle: '=?',
showDetails: '=?bind'
}
here is a codePen that contains all the code: http://codepen.io/valecarlos/pen/bpmryw
What i want to do, is to update the header title, when one of the titles is clicked, for now i'm just trying to hardcode an update on the scope's currentTitle variable and $apply-inside the click event in the directive-, but i don't see it reflected on the header's title.
Thank you!