0
Ich bin ziemlich neu in eckigen. Ich habe meine Direktive und ich würde meine Timer() Funktion für jedes Objekt ausführen.Einmaliger Timer für jede Direktive
Mein Controller mit Daten:
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);
}
});
Meine Richtlinie:
<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 app = angular.module ("Karten", [ 'ngAnimate']);
app.directive("card", function(){
return{
restrict: 'E',
scope: {
cardInfo: '=info'
},
templateUrl: 'card.html'
};
});
und die HTML-
<div ng-app="cards" ng-controller="cardsCtrl">
<card info="changeTire" ></card>
<card info="fixTire" ></card>
</div>
eine weitere Sache, wie kann ich Timer-Variable in timerFunct zugreifen, so wird das Intervall auf geeigneten Wert eingestellt wird – Higeath
ich meine Antwort lassen bearbeiten für Sie warten. –
für Intervall zu arbeiten es erfordert Zugriff auf Intervall wie ich in der Controller-Funktion (Score, Intervall) – Higeath