首先,您没有将$ interval注入
mytimer服务,而是尝试使用它。
其次,您在
mytimer服务中遇到范围问题:
stop = $interval(function() { if (this.blood_1 > 0 && this.blood_2 > 0) { this.blood_1 = $this.blood_1 - 3; this.blood_2 = $this.blood_2 - 4; } else { this.stopFight(); }}, 100);声明函数时,您要创建一个新的作用域,这意味着该
this对象指向一个新的作用域。您可以使用
bind或使用
$this在第5行中声明的变量。(在ES2015中,您可以简单地使用arrow函数)。
同样,您在
app.js和中两次声明了模块exampleController
mytimer.js。
看看这个工作的Plunker:http
://plnkr.co/edit/34rlsjzH5KWaobiungYI?p=preview



