简体   繁体   English

使用angularjs绑定作为用户名的jQuery聊天

[英]Jquery Chat with angularjs binding as username

I am using a hand jquery plugin created by Anant Garg and to start a chat you must call the chatWith function like this onclick="chatWith('test')" where test is the username you want to open a chat with. 我正在使用由Anant Garg创建的手工jquery插件,要开始聊天,您必须调用chatWith函数,例如onclick="chatWith('test')" ,其中test是您要与之打开聊天的用户名。

I am using angularjs for the rest of my site and attempted to call the above function like so 我在我的网站的其余部分使用angularjs,并试图像上面那样调用上述函数

<a class="aclass" id="userChange" href="javascript:void(0)" onclick="chatWith('{{Users.User}}')">{{Users.User}}</a>

but that does not work and the solution would be to use ng-click but than the chatWith function does not get called on click? 但这不起作用,解决方案是使用ng-click,但是没有在单击时调用chatWith函数? Is there a angular way to do this? 有没有办法做到这一点? thanks for any input 感谢您的任何投入

You can call jquery plugin function in controller 您可以在控制器中调用jquery插件函数

First you must import jquery and plugin to your index.html before import your controller. 首先,您必须先将jquery和插件导入到index.html中,然后再导入控制器。 Then in your controller, declare a function: 然后在您的控制器中,声明一个函数:

$scope.chat = function(username){
    //call jquery plugin function
    chatWith(username);
}

In your view 在您看来

<a class="aclass" id="userChange" href="javascript:void(0)" ng-click="chat(Users.User)">{{Users.User}}</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM