项目作者: JohnnyTheTank

项目描述 :
AngularJS Factory for Wikipedia JSONP REST API
高级语言: JavaScript
项目地址: git://github.com/JohnnyTheTank/angular-wikipedia-api-factory.git
创建时间: 2016-06-17T09:46:02Z
项目社区:https://github.com/JohnnyTheTank/angular-wikipedia-api-factory

开源协议:MIT License

下载


angular-wikipedia-api-factory is an angularjs module with a wikipedia api factory.

npm version
Bower version

Author: Jonathan Hornung (JohnnyTheTank)

Usage

  1. Install via either bower, npm or downloaded files:
    1. bower install --save angular-wikipedia-api-factory
    2. npm install --save angular-wikipedia-api-factory
    3. download angular-wikipedia-api-factory.zip
  2. Include dependencies in your HTML.
    1. When using bower:
      1. <script src="bower_components/angular-wikipedia-api-factory/dist/angular-wikipedia-api-factory.min.js"></script>
    2. When using npm:
      1. <script src="node_modules/angular-wikipedia-api-factory/dist/angular-wikipedia-api-factory.min.js"></script>
    3. when using downloaded files
      1. <script src="angular-wikipedia-api-factory.min.js"></script>
  3. Add jtt_wikipedia to your application’s module dependencies

    1. angular.module('app', ['jtt_wikipedia']);
  4. Use the factory wikipediaFactory

    1. angular.module('app')
    2. .controller('appController', function($scope, wikipediaFactory){
    3. wikipediaFactory.getArticle({
    4. term: 'Oktoberfest'
    5. }).then(function (_data) {
    6. //on success
    7. });
    8. });

factory methods

searchArticles

  1. wikipediaFactory.searchArticles({
  2. term: '<TERM>', // Searchterm
  3. lang: '<LANGUAGE>', // (optional) default: 'en'
  4. gsrlimit: '<GS_LIMIT>', // (optional) default: 10. valid values: 0-500
  5. pithumbsize: '<PAGE_IMAGES_THUMBNAIL_SIZE>', // (optional) default: 400
  6. pilimit: '<PAGE_IMAGES_LIMIT>', // (optional) 'max': images for all articles, otherwise only for the first
  7. exlimit: '<EX_LIMIT>', // (optional) 'max': extracts for all articles, otherwise only for the first
  8. exintro: '<EX_INTRO>', // (optional) '1': if we just want the intro, otherwise it shows all sections
  9. }).then(function (_data) {
  10. //on success
  11. }).catch(function (_data) {
  12. //on error
  13. });
  1. wikipediaFactory.searchArticlesByTitle({
  2. term: '<TERM>', // Searchterm
  3. lang: '<LANGUAGE>', // (optional) default: 'en'
  4. gsrlimit: '<GS_LIMIT>', // (optional) default: 10. valid values: 0-500
  5. pithumbsize: '<PAGE_IMAGES_THUMBNAIL_SIZE>', // (optional) default: 400
  6. pilimit: '<PAGE_IMAGES_LIMIT>', // (optional) 'max': images for all articles, otherwise only for the first
  7. exlimit: '<EX_LIMIT>', // (optional) 'max': extracts for all articles, otherwise only for the first
  8. exintro: '<EX_INTRO>', // (optional) '1': if we just want the intro, otherwise it shows all sections
  9. }).then(function (_data) {
  10. //on success
  11. }).catch(function (_data) {
  12. //on error
  13. });

getArticle

  1. wikipediaFactory.getArticle({
  2. term: '<TERM>', // Searchterm
  3. lang: '<LANGUAGE>', // (optional) default: 'en'
  4. pithumbsize: '<PAGE_IMAGE_THUMBNAIL_SIZE>', // (optional) default: '400'
  5. }).then(function (_data) {
  6. //on success
  7. }).catch(function (_data) {
  8. //on error
  9. });

Wikipedia JSONP API

More angular-api-factories

bandsintown - dailymotion - facebook - flickr - footballdata - github - openweathermap - tumblr - vimeo - wikipedia - youtube

License

MIT