Giter Site home page Giter Site logo

angular-socket-io-seed's Introduction

Angular Socket.io Seed

Start an awesome app with AngularJS on the front, Socket.io + Express + Node on the back. This project is an application skeleton for writing AngularJS apps that use web sockets to add real-time functionality. If you're not planning on using web sockets, you should consider the Angular Express Seed instead.

The seed contains angular libraries, test libraries and a bunch of scripts all preconfigured for instant web development gratification. Just clone the repo (or download the zip/tarball) and you're ready to develop your application.

The seed app shows how to wire together Angular client-side components with Socket.io and Express on the server. It also illustrates writing angular partials/views with the Jade templating library.

Note: Although Jade supports interpolation, you should be doing that mostly on the client. Mixing server and browser templating will convolute your app. Instead, use Jade as a syntactic sugar for HTML, and let AngularJS take care of interpolation on the browser side.

How to use it

Clone the angular-socket-io-seed repository and start hacking!

Running the app

Runs like a typical express app:

node app.js

Running tests

Coming soon!

Receiving updates from upstream

Just fetch the changes and merge them into your project with git.

Updating angular.js

Alternatively, you can update AngularJS with Bower:

bower update angular

Example Application

I created a simple instant messaging application and wrote a blog post walking through the app to illustrate using the seed.

Directory Layout

app.js                  --> app config
bower.json              --> for bower
package.json            --> for npm
public/                 --> all of the files to be used in on the client side
  css/                  --> css files
    app.css             --> default stylesheet
  img/                  --> image files
  js/                   --> javascript files
    app.js              --> declare top-level app module
    controllers.js      --> application controllers
    directives.js       --> custom angular directives
    filters.js          --> custom angular filters
    services.js         --> custom angular services
  bower_components/
    angular/            --> angular.js
    angular-socket-io/  --> socket.io adapter for angular
routes/
  index.js              --> route for serving HTML pages and partials
views/
  index.jade            --> main page for app
  layout.jade           --> doctype, title, head boilerplate
  partials/             --> angular view partials (partial jade templates)
    partial1.jade
    partial2.jade

Contact

For more information on AngularJS please check out http://angularjs.org/ For more on Express and Jade, http://expressjs.com/ and http://jade-lang.com/ are your friends.

angular-socket-io-seed's People

Contributors

btford avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-socket-io-seed's Issues

testing

Hi,

Nice tutorials, thanks.

How would you go about writing tests for a setup like this one?

mock socket.io server connection in the unit tests in the angular client and vice versa?

angular e2e tests for client and server together?

Regards,

Remko

no method "address"

Running node.exe under windows7 it was really complex to install these dependencies (npm install do not work) :

  • socket.io
  • socket.io-client
  • uglify.js
  • activex-offuscator

And finally, after a really complex manual installation i got this traceback :

C:\temp >> node app.js

Warning: express.createServer() is deprecated, express
applications no longer inherit from http.Server,
please use:

var express = require("express");
var app = express();

Socket.IO's listen() method expects an http.Server instance
as its first parameter. Are you migrating from Express 2.x to 3.x?
If so, check out the "Socket.IO compatibility" section at:
https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to-3.x
info - socket.io started

C:\temp\angular-socket-io-seed\app.js:52
console.log("Express server listening on port %d in %s mode", app.address().
^
TypeError: Object function app(req, res){ app.handle(req, res); } has no method 'address'
at Server. (C:\instances\appjs\angular-socket-io-seed\app.js:52:69)
at Server.g (events.js:185:14)
at Server.EventEmitter.emit (events.js:85:17)
at Server._listen2 (net.js:921:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)

$scope.messages needs declaration

I was getting a problem sending messages and it's because $scope.messages was never defined, so when we tried to push a message to it we were getting an error. Doing this solved the problem:

controllers.js:

function AppCtrl($scope, socket) {

  $scope.messages = [];

  // Socket listeners
  // ================

  socket.on('init', function (data) {

...

I figured it was such a small change that it would be easier to submit an issue than a pull request.

jQuery UI Layout Plug-in

Hi Brian,
I've recently taken an old fiddle created by Igor (http://jsfiddle.net/IgorMinar/jfn5z/3/) and updated all libs in the following plunk (
http://plnkr.co/edit/BXFqYzG6iyyHVz5r2KBD?p=preview
) which is working great. I've tried using this with your seed and only get the display below with no errors appearing in console. I've updated the (https://github.com/johntom/angular-socket-io-seed) with the directive and a sample partial called testLayout.js.
Any ideas appreciated,
John

Display:
angular-1.0.5Toggle bodyStatetrue
West
Center
East
South

Add Mongoose

Add Mongoose to make your project perfect! :)

unhandled socket.io url

When I clone this project and start it up I get a repeated "info - unhandled socket.io url" message in the terminal

$ node app
   info  - socket.io started
Express server listening on port 3000
   info  - unhandled socket.io url
   info  - unhandled socket.io url
   info  - unhandled socket.io url
   info  - unhandled socket.io url
   info  - unhandled socket.io url
   info  - unhandled socket.io url
   info  - unhandled socket.io url
   info  - unhandled socket.io url

client socket.emit('send:message', {message:msg}); not work

public\js\controllers.js

  controller('MyCtrl2', function ($scope,socket) {
     $scope.holo=function(){
    var msg=$scope.msg;
	alert(msg);
	socket.emit('send:message', {message:msg});
     //	   socket.emit('send:name', {    name:msg  });

	 };

  
  });

\views\partials\partial2.jade

div(ng-controller='MyCtrl2')
  input(ng-model="msg")
  button(ng-click="holo()") 'send:message' 

alert works but socket.emit('send:message' did nothing

Update to 1,0.4

Hi Brian,
I've forked your seed to (https://github.com/johntom/angular-socket-io-seed) to illustrate some of the issues I've had mostly combined with angular 1.0.4. In most cases, I can get these to controls work fine with a plunker example but my real world samples have proved more challenging. Since I've developed a few prototype apps and two production apps based on this seed and can't thank you enough for your blog and contributions. That said, since I use different database back ends (mysql and firebird) and I've had a difficult time explaining some of the issues I've come across and decided that a fresh start with a proper fork, eliminating the database from the equation might be the best path to document the issues and hopefully can be resolved by shinning the light on my mistakes or perhaps validating these as conflicts. I've included both 1.0.3 and 1.0.4 to make it very easy to change the library and test. The following tests use the latest angular-ui, jquery and bootstrap libs along with normal css reference used in the demos.

  1. Changed references to angular 1.0.4 and renamed angular directory to angular103.
    a) All tests worked fine
  2. Added Faq partial to illustrate the accordion issue
    a) A simple change to angular to 1.0.4 from 1.0.3 by toggling comment line 33/34 in index,jade illustrates what happens when testing the accordion with 1.0.4. By clicking on a group header the form will blow out the the default view. The exact same code works fine with 1.0.3
  3. I've included a few select2 controls to illustrate my problems with this control with both 1.0.4 and 1.0.3 and this enviornment.
    a)select view2 and press (choose second) . Same blow out described above
    b)clicking on the dropdown button also blows out form
    c)Pressing in the select2 box and holding down the left button mouse will let you select an option. Not useful for end user but I think it helps illustrate problem with the click event.
    d)Select Select2 partial form to see regular select lists working fine.
    e)If you change to 1.0.3 pressing (choose second) works fine but pressing drop down button blows up
  4. I haven't included ng-grid but problem occurs when selecting the menu group option.
  5. I will also post on the angular-ui hub
    Hope that's clear and thanks,
    John

Address from socket

How to I change the socket.io address? i pretend use this app in non node app front end, and i want use angular and socket.io

Update the tutorial that spawned this repo

You wrote this tutorial on html5rocks, correct? And afterwards, created the btford angular-websocket NPM/bower package, right? In your article, you mention:

I may revisit writing a complete wrapper, but that's beyond the scope of this tutorial.

It may be worth heading back to that article and editing it to point to your npm/bower package. It's the first google result for "angular and socketio."

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.