Created
May 23, 2017 12:32
-
-
Save karthickvkumar/638ef98f035d79620353da37cabc810e to your computer and use it in GitHub Desktop.
This file contains 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 characters
<!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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment