这是我的 fiddle :http://jsfiddle.net/ZYJsK/302/
我想为这个网站的文本制作动画:http://vegas.jaysalvat.com/
我的JS:
var app = angular.module("app", []);
app.controller('mainCtrl', function ($scope,$element) {
var texts = ["example1", "example2", "example3"];
var textToAdd = angular.element("#sizin");
var count = 0;
function changeText (){
textToAdd.text(texts[count]);
count < 3 ? count++ : count = 0;
}
setInterval(changeText,500);
});
任何建议都很好?百万感谢
最佳答案
您应该绑定(bind)到范围变量并通过计时器更改它并调用 $apply
。
像这样。
$scope.initComVal = '.com';
$scope.comval = '';
function changeText (){
if($scope.comval.length === $scope.initComVal.length)
$scope.comval = '';
else
{
$scope.comval = $scope.initComVal.substring(0, $scope.comval.length+1);
$scope.$apply();
}
}
关于javascript - 使用 javascript/Angular 动画文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33323175/