I'm encountering an issue with a directive that has 2-way data binding scope. Here's the code snippet:
app.directive('channelStar', function() {
return {
restrict: "E",
template: 'This is working as expected : {{count}}',
scope: {
count: '='
},
link: function(scope, element, attrs) {
// The count value displays in the template but isn't updating here
// It seems to be logging the old scope value
console.log(scope.count);
}
}
});
In my routing template (using ui-router and nested states):
<channel-star count="selectedChannel[0].channel_dir_members"></channel-star>
Controller:
httpService.request(...).then(function(result){
$scope.selectedChannel = result.data;
$rootScope.selectedChannel = result.data;
// $scope.$applyAsync();
// $rootScope.$applyAsync();
})
Any suggestions on how to address this issue?