angularjs - Angular directive callback isn't working -


i'm sure i'm making mistake can't find it. html:

<html ng-app="countdown">   <body>     <div class="container" ng-controller="cc">       {{status}}<br>       <countdown duration="3" timeoutcallback="cbck"></countdown>     </div>   </body> </html> 

that's javascript code:

var app = angular.module("countdown",[]);  app.controller('cc', function ($scope){   $scope.status = 'countdown started ';   $scope.cbck = function () {     $scope.status = 'countdown finished';   } }); app.directive('countdown', ['$interval', function ($interval) {   return {     scope: {       timer: '=duration',       callback: '&timeoutcallback'     },     restrict: 'e',     template: '<span>{{minutes}}:{{seconds}}</span>',     link: function (scope, element, attrs){        scope.ipromise = $interval(function() {         var minutes, seconds;         minutes = parseint(scope.timer / 60, 10)         seconds = parseint(scope.timer % 60, 10);         scope.minutes = minutes < 10 ? "0" + minutes : minutes;         scope.seconds = seconds < 10 ? "0" + seconds : seconds;         if(scope.timer > 0){              scope.timer--;            }else{           scope.callback();           $interval.cancel(scope.ipromise);         }       }, 1000);     }   }; }]); 

i can't find i'm doing wrong, developed directives callbacks , work well.

here code: http://codepen.io/madridserginho/pen/jdwnek

what @arek said...

also use: callback: '=timeoutcallback'

rather callback: '&timeoutcallback'

http://codepen.io/anon/pen/pqpmgx


Comments