Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-sails

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-sails

An angular provider for using the sails socket.io api

  • 2.0.0-beta.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
increased by6.25%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

Angular Sails

This 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

You must also include sails.io-client in order to use this.

Switching from angular's $http?

Angular Sails is a drop-in replacement for Angular's $http service. If you are currently using $http with sailsjs then switching to sockets is a snap, just replace $http with $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 () {
    // Using .success() and .error()
    $sails.get("/bars")
      .success(function (data, status, headers, config) {
        $scope.bars = data;
      })
      .error(function (data, status, headers, config) {
        alert('Houston, we got a problem!');
      });

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

    // Watching for updates
    $sails.on("bars", function (message) {
      if (message.verb === "created") {
        $scope.bars.push(message.data);
      }
    });
  }());
});

API Reference

Sails.JS REST

Angular Sails mimics Angular's $http service to provide a drop-in socket replacement for http. For more information check out angular's $http docs
Note: Angular Sails does not have a jsonp method as jsonp is a specific implementation of HTTP

FAQs

Package last updated on 21 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc