0
我尝试在视图和模态中获取相同的定时器。 用相同的范围这两个工作:示波器角度模态和角度定时器指令
$scope.openTimer = function() {
var modalInstance = null;
modalInstance = $modal.open({
templateUrl: 'modal-timer.html',
controller: 'ModalTimerController',
scope: $scope,
backdrop: 'static',
size: "sm"
});
modalInstance.result.then(function() {
console.log('onCloseModal');
});
}
这是我plunker。
我遇到的问题是我无法在视图和模态之间共享运行时间(来自定时器指令)。模态总是以重置计时器打开。
有什么办法可以在视图和模态中共享完全相同的定时器运行时间吗?
我做了你所说的并使用[this](http://www.bennadel.com/blog/2674-creating-a-reusable-timer-in-angularjs.htm)来帮助我正确实现它。一切正常,我想要。我开始为angular [here](http://louisamoros.github.io/angular-timer/#/home)实现其他指令/服务计时器。 –