加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 角度定时器不工作

发布时间:2020-12-17 17:59:50 所属栏目:安全 来源:网络整理
导读:我想显示倒计时器.我一直在参考以下页面 http://siddii.github.io/angular-timer/ 但我得到以下错误. Error: Invalid isolate scope definition for directive timer: @? 谁能告诉我我错过了什么? 的index.html !DOCTYPE htmlhtml ng-app="app"headmeta cha
我想显示倒计时器.我一直在参考以下页面
http://siddii.github.io/angular-timer/

但我得到以下错误.

Error: Invalid isolate scope definition for directive timer: @?

谁能告诉我我错过了什么?

的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>

app.js

var appModule=angular.module('app',['timer']);

解决方法

试试这个.它的工作原理是:

我根据我得到的错误添加了moment.js和humanizeDuration.js库.

希望能帮助到你

<!DOCTYPE html>
<html>

  <head>
   <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.1/angular.min.js"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.3/moment.js"></script>
   <script src="https://raw.githubusercontent.com/EvanHahn/HumanizeDuration.js/master/humanize-duration.js"></script>
   <script src="https://raw.githubusercontent.com/siddii/angular-timer/master/dist/angular-timer.js"></script>
  </head>

   <body ng-app="app">

    <div ng-controller="ctrl">
      <timer end-time="1451628000000">{{days}} days,{{seconds}} seconds.</timer>
	</div>
	
	<script>
	   var app = angular.module('app',['timer']);
			
	   app.controller('ctrl',function($scope){});
	</script>
   </body>
</html>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读