Spade
Spade

Reputation: 591

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.

I am using angularjs for the rest of my site and attempted to call the above function like so

<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? Is there a angular way to do this? thanks for any input

Upvotes: 1

Views: 205

Answers (1)

nnc1311
nnc1311

Reputation: 89

You can call jquery plugin function in controller

First you must import jquery and plugin to your index.html before import your controller. 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>

Upvotes: 2

Related Questions