⚠️ Still WIP: API is unstable and might change.
bower install --save ng-feathers
<script src="bower_components/ng-feathers/dist/ng-feathers.standalone.min.js"></script>
<script src="bower_components/socket.io-client/socket.io.js"></script>
<script src="bower_components/feathers-client/dist/feathers.js"></script>
<script src="bower_components/ng-feathers/dist/ng-feathers.min.js"></script>
npm install --save ng-feathers
<script src="node_modules/ng-feathers/dist/ng-feathers.standalone.min.js"></script>
<script src="node_modules/socket.io-client/socket.io.js"></script>
<script src="node_modules/feathers-client/dist/feathers.js"></script>
<script src="node_modules/ng-feathers/dist/ng-feathers.min.js"></script>
- REST requires jQuery as it depends on jQuery's AJAX implementation
// Add ngFeathers as dependency
angular.module('myApp', ['ngFeathers'])
// Optionally configure $feathersProvider
.config(function ($feathersProvider) {
$feathersProvider.setEndpoint('http://localhost:3030')
// You can optionally provide additional opts for socket.io-client
$feathersProvider.setSocketOpts({
path: '/ws/'
})
// true is default; set to false if you like to use REST
$feathersProvider.useSocket(true)
})
.controller('app', function ($feathers) {
var userService = $feathers.service('users')
userService.on('created', function (msg) {
console.log(msg)
})
userService.create({
username: 'john',
password: 'unicorn'
}).then(function (res) {
$feathers.authenticate({
type: 'local',
username: 'john',
password: 'unicorn'
}).then(function (result) {
console.log('Authenticated!', result)
}).catch(function (error) {
console.error('Error authenticating!', error)
})
console.log(res)
}).catch(function (err) {
console.error(err)
})
})
$feathersProvider.setAuthStorage(newAuthStorage:Object)
(default:window.localStorage
)$feathersProvider.setSocketOpts(opts:Object)
(optional)$feathersProvider.useSocket(socketEnabled:Boolean)
(default:true
)$feathersProvider.setEndpoint(newEndpoint:String)
Service-Functions (stolen from the official FeatherJS Docs)
find({query: {attr: 'value'}})
: Retrieves a list of all matching resources from the serviceget(id, {query: {fetch: 'all'}})
: Retrieve a single resource from the service.create({"text": "Example"})
: Create a new resource with data which may also be an array.update(id, {"text": "Example"})
: Completely replace a single or multiple resources.- ProTip: update is normally expected to replace an entire resource which is why the database adapters only support patch for multiple records.
patch(id, {"text": "Example"})
: Merge the existing data of a single or multiple resources with the new data.remove(id)
: Remove a single or multiple resources: