0
나는 각도가 너무 새롭다. 내 지시문이 있고 각 개체에 대해 timer() 함수를 실행하고 싶습니다. 데이터각 지시어에 대한 고유 타이머
내 컨트롤러 :
app.controller("cardsCtrl", function($scope, $interval){
$scope.changeTire = {
name: 'Change Tire',
timer: 16
};
$scope.fixTire = {
name: 'Fix Tire',
timer: 30
};
function timer(){
$interval(function(){
if($scope.countDown>0){
$scope.countDown--;
$scope.cardAnimation = {'width': +($scope.countDown/fullTimer*100)+'%' }
}
},1000,0);
}
});
내 지정 :
<div class="card">
<span class="name">{{cardInfo.name}}</span>
<span class="time">{{cardInfo.timer }}</span>
<div class="card-inner" ng-style="cardAnimation" ng-hide="finishCard"></div>
</div>
VAR 앱 = angular.module ("카드", [ 'ngAnimate']);
app.directive("card", function(){
return{
restrict: 'E',
scope: {
cardInfo: '=info'
},
templateUrl: 'card.html'
};
});
되는 HTML이있다 할
<div ng-app="cards" ng-controller="cardsCtrl">
<card info="changeTire" ></card>
<card info="fixTire" ></card>
</div>
간격이 나를 위해 내 대답을 편집 할 수 – Higeath
적절한 값으로 설정됩니다 그래서 내가 timerFunct 타이머 변수에 액세스 할 수있는 방법을 한 가지 더 기다려. –
간격으로 작동하려면 컨트롤러 기능 (점수, 간격)에서와 같이 간격에 대한 액세스가 필요합니다. – Higeath