I have a service that returns an object that has a single variable, say w, with some numeric value. I want to
build a directive that publishes that value in an HTML page. Using a link function in the directive, I tried this:
$watch(variableService.w, numToPublish,
function(variableService.w, numToPublish) {
numToPublish = variableService.w;
element.appendChild(numToPublish);
});
but I get: Uncaught SyntaxError: Unexpected token '.'
I've also tried square brackets, as in variableService['w']. Chrome developerTools console that the square bracket is the unexpected token.
Is there some recipe that will allow me to watch variables on a service?
Thanks