2014-09-11 45 views
0

我很抱歉地說代碼太大,所以我已將我的上一個問題修改爲代碼。 對不起。如何從1控制器啓動倒數計時器並顯示在其他角度

這是開始的鏈接進行

how to start a countdown timer from 1 controller and displayed in the other-angularjs

在此代碼計時器在程序啓動時,太當我們設置在第二控制器的靜態值。

任何人都可以建議我當第一個控制器(readycntrl)中的按鈕被按下,並且定時器的值是從php頁面(timer.ajax)中取出並在第二個控制器中顯示時,我可以啓動計時器(questcntrl)在計時器標籤。

<timer countdown="wow" interval="1000" finish-callback="askstart(current,total,inpu); startTimer();">{{countdown}}{{}}</timer> 

請參考上面的鏈接查看問題..

+0

可能重複(http://stackoverflow.com/questions/25665117/如何開始倒數計時器從1控制器和顯示在其他angu) – Valerij 2014-09-11 14:04:13

+0

對不起,我也是由我發佈.. – 2014-09-11 14:14:36

+0

這就是爲什麼我給了參考... – 2014-09-11 14:14:59

回答

0

嘗試使用角事件

readycntrl

$scope.click = function(){ 
    $rootScope.$broadcast("button_clicked"); 
} 

questcntrl

$scope.$on("button_clicked", function(){ 
    $scope.timerStart(VAR_FROM_PHP); 
}) 

計時器direcitive

{ 
    scope: {start: '='}, 
    link: function(scope){ 
    scope.start = function(start_time){ 
     // starting timer 
    } 
} 
} 

在HTML

<timer start="timerStart" ... /> 
的[如何從1個開始控制器倒數計時器,並在另一顯示angularjs]