I have created one custom directive using isolate scope for way data binding.
I am broadcasting event from parent to change one of the variable value and then binding this changed value to variable which is defined for two way binding in directive defination object. as given below :-
$scope.$on('updateData', function(event, data) {
//some code
$scope.datatosend = **NEW_VALUE**;
});
return {
restrict : 'E',
replace : 'true',
scope : {
datatoload : "=",
datatosend : "=", // assigning updated value to this variable
setFn : '&'
},
<locationgrid datatoload="location" datatosend="finaldata"></locationgrid>
used directive 'locationgrid' in parent template as above.
this variable is reflecting chnages on parent html template as i have tried setting that variable as ng-model for one of the textbox.
But this updated value is not reflecting in parent controller. it gives 'undefined' in parent controller , but updated value can be seen in parent html template.
Please help have spent lot of time but all in vain , tried $scope.$watch,$scope.$apply,$timeout.any help is appreciated.