问题
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.
回答1:
To get your fiddle working I changed the following:
- Changed onLoad to no wrap (body)
- Changed the framework to AngularJS 1.0.1
Here is a sample fiddle based on your original fiddle note the following changes based around bypassing jQuery for DOM/model updates:
- Angular's built in $timeout service is used instead of
setInterval
andclearInterval
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. - Whenever you update the model in JavaScript any bound UI elements will automatically be updated.
来源:https://stackoverflow.com/questions/12224078/angular-jsfiddle-example-doesnt-work