I implemented the $watch
function, but the code within it throws an error if panodatas is undefined
:
scope.$watch('panodatas', function(newVal) {
if ('isCreate' in attrs) {
$('.modal #points').hide()
$('.modal #points-info').hide()
}
if (newVal || 'isCreate' in attrs) {
scope.x = 0
scope.y = 0
scope.points = []
The challenge lies in the fact that the code executes every time panodatas
changes.
Is there a way to ensure that $watch
only triggers once and not on subsequent changes to panodatas
?