角度计时器指令不适用于离子框架 [英] angular timer directive not working with ionic framework

查看:47
本文介绍了角度计时器指令不适用于离子框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用离子框架实现角度计时器指令时遇到问题.http://siddii.github.io/angular-timer/

当我使用 bower 或 google cdn 实现代码时,我没有任何问题.

 <头><title>Plain Javascript Timer 示例</title><script src="../bower_components/angular/angular.min.js"></script><script src="../app/js/timer.js"></script><脚本>函数开始定时器(){document.getElementsByTagName('timer')[0].start();}函数 stopTimer() {document.getElementsByTagName('timer')[0].stop();}<身体><div><h2>Plain JavaScript - 计时器示例</h2><h3><timer ng-app="timer"/></h3><button onclick="startTimer()">启动定时器</button><button onclick="stopTimer()">停止计时器</button>

<br/></html>

但是当我使用离子束时http://code.ionicframework.com/1.0.0-beta.13/js/ionic.bundle.js我无法让计时器工作.并且似乎没有在控制台中收到任何错误.

这是一个已知问题吗?

什么会阻止它工作?

是否有可供人们推荐的备用计时器?这个对我来说似乎是最好的?

解决方案

尝试在此处查看此代码示例:http://siddii.github.io/angular-timer/examples.html#/angularjs-single-timer

以角度启动计时器是通过

完成的

$scope.$broadcast('timer-stop');

不是

element.start();

顺便说一句,你的 ng-app 应该在 html/body 标签中,而不是在 timer 标签中.

I am having issues with implementing the angular timer directive with the ionic framework. http://siddii.github.io/angular-timer/

When I implement the code using bower or the google cdn I have no issues.

    <!DOCTYPE html>
    <html>
    <head>
    <title>Plain Javascript Timer Example</title>
    <script src="../bower_components/angular/angular.min.js"></script>
    <script src="../app/js/timer.js"></script>
    <script>
    function startTimer() {
    document.getElementsByTagName('timer')[0].start();
    }
    function stopTimer() {
    document.getElementsByTagName('timer')[0].stop();
    }
    </script>
    </head>
    <body>
    <div>
    <h2>Plain JavaScript - Timer Example</h2>
    <h3><timer ng-app="timer"/></h3>
    <button onclick="startTimer()">Start Timer</button>
    <button onclick="stopTimer()">Stop Timer</button>
    </div>
    <br/>
    </body>
    </html>

However when I use the ionic bundle http://code.ionicframework.com/1.0.0-beta.13/js/ionic.bundle.js I can not get the timer to work. And do not seem to get any errors in the console.

Is this a known issue?

What would be stopping it from working?

Is there an alternate timer that people can reccomend? This one seemed the best to me?

解决方案

try looking at this code sample here: http://siddii.github.io/angular-timer/examples.html#/angularjs-single-timer

starting the timer in angular is done via

$scope.$broadcast('timer-stop');

not

element.start();

BTW, your ng-app should be in the html/body tag, not in the timer tag.

这篇关于角度计时器指令不适用于离子框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆