我想显示倒计时器.我一直在参考以下页面
http://siddii.github.io/angular-timer/
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>