Skip to content

JetFault/angular-sails

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Angular Sails

This small module allows you to use Sails.JS's awesome socket.io api with AngularJS.

Just add a dependency to your module and controllers and get it going!

Install it:

bower install angular-sails

Usage

A small example:

var app = angular.module("MyApp", ['ngSails']);

//OPTIONAL! Set socket URL!
app.config(['$sailsProvider', function ($sailsProvider) {
    $sailsProvider.url = 'http://foo.bar';
}]);

app.controller("FooController", function ($scope, $sails) {
  $scope.bars = [];

  (function () {
    $sails.get("/bars")
      .success(function (data) {
        $scope.bars = data;
      })
      .error(function (data) {
        alert('Houston, we got a problem!');
      });


    $sails.on("message", function (message) {
      if (message.verb === "create") {
        $scope.bars.push(message.data);
      }
    });
  }());
});

API Refenrence

Sails.JS REST

Angular Sails wraps the native sails.js REST functions. For further information check out the sails docs and Mike's Screencast

Native socket functions

The sails service is nothing more like the native socket.io object!

About

An angular module for using the sails socket.io api

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%