import { Component, OnInit, Inject } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { DOCUMENT } from '@angular/common';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { NgbModalConfig, NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { AppsService } from '../services/apps.service';
import { IApps, Apps, IDataUser, DataUser, IClient, Client, IAppData, AppData } from '../models/apps.model';
import { NgxSpinnerService } from 'ngx-spinner';
declare var require: any;
@Component({
selector: 'rss-channel-content',
templateUrl: './rss-channel.component.html',
styleUrls: ['./rss-channel.component.scss'],
providers: [
AppsService,
NgbModalConfig,
NgbModal
]
})
export class RssChannelComponent implements OnInit {
public isGallery: boolean = false;
public is_view: boolean = false;
public is_save: boolean = false;
private id_app: string;
public structure_app: IApps = new Apps();
public form_data_user: FormGroup;
public href: string = '';
public url: string = '';
public ocultar: boolean = false;
public feed = require('rss-to-json');
public rss: any;
constructor(
private appsService: AppsService,
private route: ActivatedRoute,
private modalService: NgbModal,
private router: Router,
private spinner: NgxSpinnerService,
private titleService: Title,
@Inject(DOCUMENT) private _document: HTMLDocument
) { }
ngOnInit() {
this.spinner.show();
this.id_app = this.route.snapshot.params['id'];
this.getApplication();
this.getUrl();
}
private getUrl() {
this.href = this.router.url;
console.log(this.router.url);
this.url = this.appsService.getUrl(this.href);
console.log('url', this.url);
}
private getApplication() {
this.appsService.getApp(this.id_app).subscribe(async (response) => {
console.log('response', response);
this.structure_app = response.response.options;
this.titleService.setTitle(this.structure_app.name_app);
this._document.getElementById('appFavicon').setAttribute('href', this.structure_app.icono_app);
this.rss = await this.valueRss();
this.is_view = true;
}, (error) => {
console.log(error);
});
}
valueRss() {
return new Promise((resolve, reject) => {
console.log(this.structure_app.rss_url);
this.feed.load(this.structure_app.rss_url, function (err, rss) {
console.log(rss);
resolve(rss);
});
this.spinner.hide();
});
}
/**
* changeColor
*/
public changeColor(col: string, amt: any) {
amt = amt === undefined ? -30 : amt;
col = col === undefined ? '#eee' : col;
return this.appsService.changeColor(col, amt);
}
public open(e: any) {
this.modalService.open(e, { centered: true, size: 'lg' });
}
}
explanation:when i call this getApplication api method,inside that method,i am calling valueRSS function,
but its giving this.feed.load is not a function and also giving me process is not defined
i am using angular 10 and rss-to-json version 1.0.5.
basically in that api we have response of rss url,so we are converting that rss url to json data and displaying it to html
question from:
https://stackoverflow.com/questions/65931812/error-uncaught-in-promise-typeerror-this-feed-load-is-not-a-function-typeer 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…