Created
May 23, 2017 12:32
-
-
Save karthickvkumar/638ef98f035d79620353da37cabc810e to your computer and use it in GitHub Desktop.
Revisions
-
karthickvkumar created this gist
May 23, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ <!DOCTYPE html> <html> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <body> <div ng-app="myApp" ng-controller="myCtrl"> {{data.time}} <br/> <button ng-click="updateTime()">update time - ng-click</button> <button id="updateTimeButton" >update time</button> </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.data = { time : new Date() }; $scope.updateTime = function() { $scope.data.time = new Date(); console.info($scope.data.time) } document.getElementById("updateTimeButton") .addEventListener('click', function(){ $scope.data.time = new Date(); /* $scope.$digest() //or $scope.$apply(function() { $scope.data.time = new Date(); });*/ }) }); </script> </body> </html>