I m trying to chain a promise to my 'timeout/typewriter effect' function, so once he function is finished another function should be called which is a simple $state.go. Ive been researching and looking at so many posts but whatever I try doesnt work-the first function is never being executed /or probably being executed but so fast that you cant see anything-instead just the second (the $state.go) function is being executed right away. Any ideas would be very much appreciated. Thank you!
app.controller('homeCtrl', function($scope, $state, $q, $interval, $timeout) {
function beginn() {
var content = "helloo"
$scope.typewriter = "";
var i = 0;
var timer = $interval(function() {
if (i < content.length)
$scope.typewriter += content[i];
else {
$interval.cancel(timer);
}
i++;
}, 300)
}
function change() {
$state.go('profile')
}
$q.when(beginn()).then(change);
});
html:
<p>{{typewriter}}</p>