Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Swathi Kasoju
PLUS
Swathi Kasoju
Courses Plus Student 8,458 Points

AngularJs chat application with NodeJs using Express websocket

Hi, I am new to AngularJs and NodeJS. I am trying to build a AngularJS chat application using NodeJs Express Websocket. I tried to find the examples for my reference but of no use. I am not able to print the messages to the chat container but I am able to print the message to the console. Can someone help me with your idea or expertise. HTML code to print messages: <div ng-repeat="message in messages"> <div class="sentmessage"> <span class="username">{{ message.from }}:</span> {{ message.msg }} </div> </div>

JS file code: $scope.messages = [];
ws.onmessage = function (message) { var json = angular.fromJson(message.data); $scope.messages.push(message.data); };

And also can you help me with how to update the chat messages to the DOM when response is received, without refreshing the page.

1 Answer

Thomas Dimnet
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Thomas Dimnet
Python Development Techdegree Graduate 43,629 Points

Hi there,

I saw your message: here is a sweet website which can help you to build your application.

Ok, you will not use angular, only node.js in order to build the project presented on the course but I think it can help you get started with your application.

Cheers.

Thomas