I've recently developed a directive that looks like this:
return {
restrict: 'EAC',
scope: {
statesActive: '='
},
link: function (scope, element, attrs) {
var stateData = scope.statesActive.states; // Let's not fetch data here
....
}
This is the HTML snippet where I use the directive:
<gt-map states-active="states"></gt-map>
Within the controller, I have a function for fetching states:
$scope.statesList = function () {
var query = {
status: 'active'
}
StatesList.query(query).$promise.then(function (states) {
$scope.states = states;
});
};
To display the fetched data in the states variable, I do it like this:
$scope.states = "{states:[{ 'state' : 'CA', 'color' : '#61c419']}";
How can I access the controller's scope value within the directive?
-----Added-----
When I log console.log(scope)
in my directive, this is what I see: