Socket
Socket
Sign inDemoInstall

ng-wiki

Package Overview
Dependencies
5
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ng-wiki

service provider built for Wikipedia/Angular developers. using free and anonymously Wikipedia REST API service


Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

NgWiki

Service provider built for Wikipedia/Angular developers. using free and anonymously Wikipedia REST API service

NgWiki - Basic

1. Add NgWiki package to your project

  • Run npm link ng-wiki

2. Import the HttpClientModule in your code

Add HttpClientModule to imports array within your NgModule (usually located at "src/app/app.module.ts")

@NgModule({
  imports: [
    ...
    HttpClientModule
  ],
})

3. Use in your component code

Get specified ('Jupiter') Wikipedia page content
import { Component, OnInit } from '@angular/core';
import { WikiClientService } from 'ng-wiki';

@Component({
  selector: 'app-root',
  template: '<div class="sample"><h1>{{ title }}</h1><h5>page id: {{ id }}</h5><div [innerHTML]="content"></div></div>',
  styleUrls: []
})
export class AppComponent implements OnInit {
  title: string = 'loading';
  id: number = -1;
  content: string = '<p>loding</p>';
  
  constructor(private wikiClient: WikiClientService) {
  }

  ngOnInit(): void {
    this.wikiClient
      .getPageOffline('"Hello,_World!"_program')
      .then(page => {
        this.title = page?.title || 'Error';
        this.id = page.id;
        this.content = page?.html || '<p>No page found</p>';
      })
      .catch(err => console.error(err));
  }
}

Keywords

FAQs

Last updated on 15 Mar 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc