项目
在 GitHub 查看
janpantel/angular-sails
关于
An angular module for using the sails socket.io api
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文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
You must also include sails.io.js in order to use this.
Usage
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 = 'http://foo.bar';
}]);
app.controller("FooController", function ($scope, $sails) {
$scope.bars = [];
(function () {
// Using .success() and .error()
$sails.get("/bars")
.success(function (data, status, headers, jwr) {
$scope.bars = data;
})
.error(function (data, status, headers, jwr) {
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
var barsHandler = $sails.on("bars", function (message) {
if (message.verb === "created") {
$scope.bars.push(message.data);
}
});
// Stop watching for updates
$scope.$on('$destroy', function() {
$sails.off('bars', barsHandler);
});
}());
});
API Reference
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!
探索相关项目
加载中…