Skip to content

Instantly share code, notes, and snippets.

@frozonfreak
Created December 18, 2013 07:42
Show Gist options
  • Select an option

  • Save frozonfreak/8018689 to your computer and use it in GitHub Desktop.

Select an option

Save frozonfreak/8018689 to your computer and use it in GitHub Desktop.
TypeWriter Effect using AngularJS
<!DOCTYPE html>
<html ng-app>
<head>
<meta charset="UTF-8">
<title>TypeWriter</title>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js"></script>
</head>
<body ng-controller="TypeWriterController">
<textarea ng-model="type" ng-model="cursor">{{type}}</textarea>
</body>
<script type="text/javascript">
function TypeWriterController($scope){
var content = "contentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontent";
$scope.type = "";
var i=0;
var timer = setInterval(function(){
if(i<content.length)
$scope.type += content[i];
i++;
$scope.$apply();
}, 100);
}
</script>
</html>
@Miguelowsky

Copy link
Copy Markdown

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment