angular-sails | An angular module for using the sails api

angular-sails module


Stars : 10

Forks : 10

Created by Jan-Oliver Pantel

bower install angular-sails

Download GitHub

Build Status

Angular Sails

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

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

Install it:

bower install angular-sails

You must also include in order to use this.


For a more complex example, have a look at the tutorial by Maarten.

A small example:

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

//OPTIONAL! Set socket URL!
app.config(['$sailsProvider', function ($sailsProvider) {
    $sailsProvider.url = '';

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

  (function () {
    // Using .success() and .error()
      .success(function (data, status, headers, jwr) {
        $scope.bars = data;
      .error(function (data, status, headers, jwr) {
        alert('Houston, we got a problem!');

    // Using .then()
          $scope.bars =;
      }, function(resp){
        alert('Houston, we got a problem!');

    // Watching for updates
    var barsHandler = $sails.on("bars", function (message) {
      if (message.verb === "created") {

    // Stop watching for updates
    $scope.$on('$destroy', function() {
      $'bars', barsHandler);


API Reference


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 object!


Javascript plugin