Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
how to re write this program, if i am click the button then image should blink.
$scope.blinkInterval = 0; $scope.blinkImage = function(id) { var current = $scope.view.wdg[id].visible; if (current == undefined) { current = true;} $scope.setWidgetProp(id, "visible", !current); } $scope.startBlink = function() { $scope.blinkInterval = $interval($scope.blinkImage, 1000, 0, true, "3DImage-1"); } $scope.stopBlink = function(id) { $interval.cancel($scope.blinkInterval); } angular.element(document).ready($scope.startBlink);
If I understand you want to have a button to run on click startBlink();
$scope.startBlink
You can add in the click JS area of a button widget
startBlink();
if I use this code, automatically blinking started without button click, I have to control the blink using button.
Now My Question is:
How to control the blink using button, how should I write the JS.
$scope.blinkInterval = 0; $scope.blinkImage = function(id) { var current = $scope.view.wdg[id].visible; if (current == undefined) { current = true;} $scope.setWidgetProp(id, "visible", !current); } $scope.startBlink = function() { $scope.blinkInterval = $interval($scope.blinkImage, 1000, 0, true, "3DImage-1"); } $scope.stopBlink = function(id) { $interval.cancel($scope.blinkInterval); } angular.element(document).ready($scope.startBlink);
so as @sgreywilson suggested you need to start it by the button.
In your code you have to comment the call in the ready event which is called automatically when view is loaded and ready
//comment this to avoid the automatic start
//angular.element(document).ready($scope.startBlink);