Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Latest commit

 

History

History
51 lines (40 loc) · 1.26 KB

ANGULARJS.md

File metadata and controls

51 lines (40 loc) · 1.26 KB

AngularJS

This package can be used with AngularJS version v1.6 and above.

Registering Resources


import angular from 'angular';
import {Item, Route, potion} from 'potion-client/angularjs';

angular.module('myApp', [potion.name])
    .factory('Foo', ['potion', (potion) => {
        // Remeber that resources can also be registered using `@potion.registerAs('/foo')`
        class Foo extends Item {
            static bars = Route.GET('/bar');
            name: string;
            bar = Route.GET('/bar');
        }

        // If the `@potion.registerAs('/foo')` decorator is used,
        // the below is not needed.
        return potion.register('/foo', Foo);
    }]);

Using Resources


import angular from 'angular';
import {potion} from 'potion-client/angularjs';

angular.module('myApp', [potion.name])
    .controller('MyAppController', ['Foo', (Foo) => {
        const foo = Foo.fetch(1);
    }]);

Configuring Potion


import angular from 'angular';
import {potion} from 'potion-client/angularjs';

angular.module('myApp', [potion.name])
    .config(['potionProvider', (potionProvider) => {
    	potionProvider.config({prefix: ''});
    }]);