gpt4 book ai didi

angularjs - Angular 计时器不工作

转载 作者:行者123 更新时间:2023-12-02 22:56:48 24 4
gpt4 key购买 nike

我想显示一个倒计时器。我一直在引用以下页面 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.jshumanizeDuration.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, {{hours}} hours, {{minutes}} minutes, {{seconds}} seconds.</timer>
</div>

<script>
var app = angular.module('app',['timer']);

app.controller('ctrl', function($scope){});
</script>
</body>
</html>

关于angularjs - Angular 计时器不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30342069/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com