Showing posts with label ngx-disqus. Show all posts
Showing posts with label ngx-disqus. Show all posts
<img src="https://camo.githubusercontent.com/40b59e00eb4dc8561eb73b65fba77fff77d72e8b/68747470733a2f2f63646e2e7261776769742e636f6d2f4d7572686166536f75736c692f6e67782d6469737175732f6d61737465722f6173736574732f6c6f676f2e737667" height="150" width="150"></img> <br> ngx-disqus


ngx-disqus

October 28, 2017
Add Disqus to your app instantly!

Demo

https://murhafsousli.github.io/ngx-disqus/

Installation

Install it with npm
 npm install --save ngx-disqus  

SystemJS

If you are using SystemJS, you should also adjust your configuration to point to the UMD bundle.
In your systemjs config file, map needs to tell the System loader where to look for ngx-disqus:
 map: {  
  'ngx-disqus': 'node_modules/ngx-disqus/bundles/ngx-disqus.umd.js',  
 }  

Basic usage:

Import DisqusModule in the root module
 import { DisqusModule } from "ngx-disqus";  
 @NgModule({  
  imports: [  
   // ...  
   DisqusModule.forRoot('disqus_shortname')  
  ]  
 })  
The function forRoot(shortname: string) tells the Disqus service your forum's shortname, which is the unique identifier for your website as registered on Disqus. If undefined, the Disqus embed will not load.

Now you can add Disqus component

 @Component({  
  selector: 'any-component',  
  template: `<disqus [identifier]="pageId"></disqus>`  
 })  
 export class AnyComponent {  
  pageId = '/about';  
 }  
Disqus component requires the identifier input to work properly on your app For example If the page URL is localhost:4200/about then the identifier should be /about.

More Options:

See Disqus official documentation (JavaScript configuration variables) before using these inputs.
 <disqus [identifier]="pageId" [url]="url" [category]="catId" [lang]="'en'"  
     (onNewComment)="onComment($event)" (onReady)="onReady($event)" (onPaginate)="onPaginate($event)"></disqus>  

NOTE

Angular router supports two LocationStrategy providers:
  • PathLocationStrategy: the default "HTML5 pushState" style. (Compatible with Disqus)
  • HashLocationStrategy: the "hash URL" style. (Incompatible with Disqus)
For more info check DISQUS on ajax sites

Note: Special thanks to Murhaf Sousli
Contact: murhafsousli@gmail.com
Disclaimer: The blog is created to share angular directives information to geek, curious Angular Developers.