Note that this is only a pre-build, and is not recommended for use in production code
Narrative Open Platform made easy for AngularJS. For now, all API hooks in Narratives Open Platform is not supported, for a more complete overview of what can be accomplished with this tool and with Narratives Open Platform itself can be found using the links below.
This package currently supports installation by Bower.io. With Bower installed, simply type the following in a terminal window:
$ bower install angular-narrative-api --save
Where the --save
flag saves this dependency to your bower.json
.
After installation through bower, make sure to include the source file in
your index.html
or similar after your angular import.
<script src="link/to/angular.js"></script>
<script src="bower_components/angular-narrative-api/dist/angular-narrative-api.min.js"></script>
Register an app at Narrative Open Platform, and the following snippet can help you getting started.
angular.module('app', ['api.narrative'])
.config(function (NarrativeAuthProvider , NarrativeRequestProvider) {
NarrativeAuthProvider.defaults.oauthApplication = {
clientID: "my-client-id",
redirectURI: "my-root-uri",
clientSecret: "my-client-secret"
};
// For now, Narrative does not support CORS on all URLS, so therefore a
// proxy is usually necessary.
NarrativeRequestProvider.defaults.api.proxy = 'http://cors.proxy/';
})
.controller('Controller', function (NarrativeAuth, NarrativeApi) {
// Go right ahead and use the Auth and the API!
});
Simply download the angular-narrative-api.min.js (or angular-narrative-api.js for a unminified version) and include it in a similar fashion as above in your html.
The only dependency for this module is, quite naturally, AngularJS version
1.4 or higher. For more information about development dependencies, please
see package.json
(and to some extent,
bower.json
).
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request!