Angular jsFiddle示例不起作用 [英] Angular jsFiddle example doesn't work

查看:60
本文介绍了Angular jsFiddle示例不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白为什么无法正常工作.错误是

I can't understand why this doesn't work. The error is

Error: Argument 'TodoCtrl' is not a function, got undefined

我想这个问题很简单,但是我无法解决.通常,我想定期更改文本.

I guess the issue is simple, but I can't solve it. In general, I want to change the text periodically.

推荐答案

为使您的小提琴正常工作,我更改了以下内容:

To get your fiddle working I changed the following:

  1. onLoad 更改为无包裹(正文)
  2. 将框架更改为 AngularJS 1.0.1
  1. Changed onLoad to no wrap (body)
  2. Changed the framework to AngularJS 1.0.1

这是基于原始小提琴的样本小提琴请注意以下基于绕过jQuery的更改DOM/模型更新:

Here is a sample fiddle based on your original fiddle note the following changes based around bypassing jQuery for DOM/model updates:

  1. 使用Angular内置的 $ timeout 服务代替setIntervalclearInterval,因为如果容易避免,则不应在AngularJS外部修改模型.如果要这样做,请确保并查看 $ apply
  2. 每当您使用JavaScript更新模型时,任何绑定的UI元素都会自动更新.
  1. Angular's built in $timeout service is used instead of setInterval and clearInterval since modifying the model outside of AngularJS shouldn't be done if easily avoided. If you want to do so be sure and look at $apply.
  2. Whenever you update the model in JavaScript any bound UI elements will automatically be updated.

这篇关于Angular jsFiddle示例不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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