JSColor拾取颜色以触发AngularJS ng-change [英] JSColor pick up color to trigger AngularJS ng-change

查看:161
本文介绍了JSColor拾取颜色以触发AngularJS ng-change的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是JSColor这个插件( http://jscolor.com/) 并将输入值与AngularJS ng-model绑定,如下所示:

I use this plugin, JSColor (http://jscolor.com/) and bind the input value with AngularJS ng-model like the following:

<input class="color" ng-model="myColor" ng-change="alert(myColor)">

我希望每次获取颜色时,AngularJS都会提醒myColor的值已更改,但是什么也没发生.

I expect everytime I pick up a color AngularJS will alert the changed value of myColor, but nothing happens.

我还应该做什么?谢谢你! :)

What else should I do? thank you! :)

添加:

我也尝试过:

<input class="color" ng-model="myColor"> 
<textarea style="color:#{{myColor}}>texttext</textarea> 

绑定文本区域中的文本颜色,也不起作用.

to bind text color in textarea, also doesn't works.

推荐答案

由于调用了警报,因此未触发您的值班变更. ng-change ="alert(myColor)"

Your on-change is not fired because of the alert called. ng-change="alert(myColor)"

   $scope.alert = function(myColor) {
   alert(myColor);
}

这篇关于JSColor拾取颜色以触发AngularJS ng-change的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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