I have the following problem: I have a function inside a controller, and the function decides the value of a $scope.name
app.controller('myController', ['$scope', function($scope) {
function myFunction() {
$scope.name = 'myName';
}
document.getElementById('my-id').addEventListener("click", myFunction);
}])
I cannot use ng-click for multiple reasons. UPDATE: I cannot use ng-click due to photoswipe gallery and socialshare. I want to add custom FB share, and if I use ng-click it will close the photoswipe opened image. Please see the example here. Open an image and click on the top-left custom share button
Note, even if I use the example here, it will not bind my $scope.name to the html.
If I try to log the value it works as a charm, eg.
console.log($scope.name); //will work perfectly
In the html it will not bind the value:
<div ng-controller="myController">
<button id="my-id">
<p>{{name}}</p>
</button>
</div>
document.getElement...). This question is answerable per se (digest cycle is being bypassed), but to get a real Angular answer you need to change your approach. For that we'd need to know what problem you have withng-click.$scope.$applybut as @deceze said your doing it wrong this way.ng-clickand photoswipe; it's too vague what exactly the issue is, but I'm pretty sure there's no reason it can't be solved.