angularjs 在输入中创建随机占位符

angularjs make random placeholder on input

我尝试在输入中随机生成占位符文本。 这是我的 sample code

尝试运行这个示例几次,然后您可能会通过控制台看到错误代码。

Error: 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations:

即使更改了占位符文本,也请打扰此错误消息。 为什么此代码有时有效,有时无效?

来自this的回答:

You shouldn't change objects/models during the render or otherwise it will force a new render (and consequently a loop, which causes the 'Error: 10 $digest() iterations reached. Aborting!').

If you wan to update the model, do it on the Controller or on a Directive, never on the view. angularjs documentation recommends not to use the ng-init exactly to avoid these kind of situations:

Use ngInit directive in templates (for toy/example apps only, not recommended for real applications)

您的随机函数触发 $digest() 错误 这是 angular js 中关于它的问题:-

Random function triggering $digest() error

我进行了搜索,但找不到解决方法。