Zeppelin angular client-first is defined as an %angular paragraph with generated HTML output which is activated by an auto-run script:
<script>
changeValue($scope, value) {
$scope.myValue=value
}
(function() {
...
$scope.changeValue = angular.bind($scope, v => { changeValue($scope, v) });
$scope.z.runParagraph(serverHandlerParagraphId);
})()
</script>
Therefore, the server side %spark paragraph is executed once setting up some angular watches to respond on client angular events
z.angularBind("myValue",null)
z.angularUnwatch("myValue")
z.angularWatch("myValue",(before,after,ctx) => {
// server handler for myValue changes is here
})
Serve-side angular watch handler is not triggered when angular variable on client is not initialized first or initialized as undefined:
<script>
changeValue($scope, value) {
$scope.myValue=value
}
(function() {
...
$scope.myValue=undefined
$scope.changeValue = angular.bind($scope, v => { changeValue($scope, v) });
$scope.z.runParagraph(serverHandlerParagraphId);
})()
</script>
Serve-side angular watch handler is triggered when angular variable on client is initialized to some dummy value:
<script>
changeValue($scope, value) {
$scope.myValue=value
}
(function() {
...
$scope.myValue="None"
$scope.changeValue = angular.bind($scope, v => { changeValue($scope, v) });
$scope.z.runParagraph(serverHandlerParagraphId);
})()
</script>
The value doe not matter, because the first value the server side handler is going to recieve when triggered very first time will be null, due to server side initialization:
z.angularBind("myValue",null)
Create a new zeppelin note using the code below. Make sure paragraphId varaible points to your server side spark paragraph.
1 Try to leave ax4value not initialized 2 Click buttons to see whether the changes trigger server side handler 3 Try to clone zeppelin note 4 Try to restart spark interpreter
1 Initialize ax4value="None" 2 Click buttons to see whether the changes trigger server side handler 3 Try to clone zeppelin note 4 Try to restart spark interpreter