angular-sails 介绍
angular-sails 是使用 Sails Socket.io API 的
AngularJS 模块。
据说,用了 Angular-sails,从此告别 Ajax!
安装
bower install angular-sails
使用示例
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); } }); }()); });
angular-sails 官网
https://github.com/janpantel/angular-sails
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。