2017-07-03 38 views
0

我想在我的离子3进Web应用程序使用此NPM模块:https://www.npmjs.com/package/ngx-disqusNGX-disqus模块只显示一个线程

我把它导入到这样的page.module.ts:

import { DisqusModule } from 'ngx-disqus'; 
 
    
 
@NgModule({ 
 
    declarations: [ 
 
    SzenarioerstellungPage, 
 
    ], 
 
    imports: [ 
 
    IonicPageModule.forChild(SzenarioerstellungPage), 
 
    DisqusModule.forRoot('my_shortname'), 
 
    ], 
 
    exports: [ 
 
    SzenarioerstellungPage 
 
    ] 
 
}) 
 
export class SzenarioerstellungPageModule {}

这是我如何使用它的mypage.html文件:

<disqus [identifier] = "pageId" ></disqus>

这就是我如何设置pageId

ionViewDidLoad() { 
 
    this.szenarioProvider.getUserID().then(UID => { 
 
     this.pageId = UID; 
 
    }); 
 

 
    }

正如你所看到的,我想使用的用户的唯一ID(这是他从拿到Firebase认证)在他的页面上显示一个独特的讨论线程。

现在的问题是,无论用户何时进入此页面,铁饼只会显示一个相同的线程,而不是每个用户的单独线程。

注:无论什么用户进入页面提到,它总是有相同的URL(离子确实是这样的。):http://localhost:8100/#/szenarioerstellung 但我想,这独特的[indentifier]将解决这个问题。

你知道吗,我做错了什么或者我需要添加什么?

+1

[在角2应用Disqus。:显示相同的讨论]的可能的复制的要求部分(https://stackoverflow.com/questions/43095097/disqus-in-angular-2-application -showing-same-discussion) – n00dl3

+0

我认为我的问题是另一个问题。我不想在我的页面上有多个disqus线程。我想要disqus加载属于进入页面的用户的唯一ID的线程。或者你的意思是,我不能解决我的问题,只有一个线程根据唯一的ID更改其内容? –

+0

简短回答:ngx-disqus是非常无用的,可以构建你自己的disqus组件,并在需要时调用DISQUS.reset()方法:https://help.disqus.com/customer/portal/articles/472107-using-disqus -on-ajax-sites – n00dl3

回答

0

DISQUS在路由器中使用#时不起作用。

例如,URL http://localhost:8100/#/szenarioerstellung被读为http://localhost:8100/,因此无论URL如何变化,它在DISQUS方面仍然看起来相同。

有2个解决方案:

1 - 找到一种方法来配置你的路由器使用hashbang #!而不是#

2 - 从路由器禁用HashLocationStrategy所以它变得像标准的URL http://localhost:8100/szenarioerstellung

阅读Using Disqus on AJAX sites

+0

我用'@角度/路由器'导入{路由,路由器模块};'为了避免#在URL中。但是,disqus只显示一个线程。所以我认为#并不是唯一的问题。 你有什么建议吗? –