Angularjs 角度计时器不工作

Angularjs 角度计时器不工作,angularjs,angular-timer,Angularjs,Angular Timer,我想显示一个倒计时。我已经参考了下一页 但是我得到了下面的错误 错误:指令计时器的隔离作用域定义无效:@ 谁能告诉我我错过了什么 index.html <!DOCTYPE html> <html ng-app="app"> <head> <meta charset="ISO-8859-1"> <title>Insert title here</title> <script type="text/javascript"

我想显示一个倒计时。我已经参考了下一页

但是我得到了下面的错误

错误:指令计时器的隔离作用域定义无效:@

谁能告诉我我错过了什么

index.html

<!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="angular-timer.min.js"></script>
<script type="text/javascript" src="app.js"></script>
</head>
<body>
<timer end-time="1451628000000">{{days}} days, {{hours}} hours, {{minutes}} minutes, {{seconds}} seconds.</timer>
</body>
</html>

试试这个。它正在工作:

我根据收到的错误添加了和库

希望能有帮助


{{天}天{小时}小时{{分钟}分钟{秒}秒。
var app=angular.module('app',['timer']);
app.controller('ctrl',函数($scope){});

您需要拉入正确的库才能使计时器工作

bower install momentjs --save
bower install humanize-duration --save
现在在HTML中添加依赖项

<script type="text/javascript" src="bower_components/humanize-duration/humanize-duration.js"></script>

<script type="text/javascript" src="bower_components/momentjs/min/moment-with-locales.min.js"></script>


您使用的Angular版本是什么?谢谢您的回复。我将AngularJS升级到了AngularJS v1.1.4,并包含了moment.js和humanize.js。现在会显示计时器,但计时器不会滴答作响。只有当我刷新页面时,计时器才会更改。您有任何错误吗?您是否按原样尝试了上面的工作HTML代码?也可以尝试使用Angular 1.3。1@JcDenton86如何使用控制器作用域而不是隔离作用域?@N.V.Prasad,这是一个新问题(在您的评论中)?我的回答解决了你的问题吗?
<script type="text/javascript" src="bower_components/humanize-duration/humanize-duration.js"></script>

<script type="text/javascript" src="bower_components/momentjs/min/moment-with-locales.min.js"></script>