Scope of an AngularJS scope variable
I have this in my HTML
{{searchDialog.visible}}
and this in my controller
$scope.searchDialog = {'visible' : false}; // initialize
$scope.MarkerClicked = function(e)
{
$scope.searchDialog.visible = true;
}
These are the only mentions of $scope.searchDialog
. I beakpoint the $scope.MarkerClicked
function and watch the value toggle to true, but the HTML never changes.
What am I doing wrongly? Is there a scope problem (no pun intended)?
Aha!! $scope.MarkerClicked
is a callback from clicking a Leaflet map marker
var marker = L.marker(pubLatLng,
{
draggable: false,
title: title,
icon: new L.DivIcon({
html: '<img class="my-div-image" src="js/3rd_party/leaflet/images/'
+ iconImage + '" />'
+ '<span style="color:red">' + companyName + '</span>',
})
}).addTo($scope.map).on('click', $scope.MarkerClicked);
Is that somehow causing my problem? I can't see how, as the marker is added in a $scope
function and the callback also handled in a $scope
function.