Good Day Everyone ,
This is my first post in this forum , i am new to Angular.
i have a service that i created and it is defined like this
TrendingChannelsService.ts
import { Injectable } from '@angular/core';
import {HttpClient} from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class TrendingChannelsService {
constructor(private http:HttpClient) {}
GetChannels() :any
{
let url ="https://trovadating.com/TrovaTVApi/channels";
return this.http.get<any>(url);
}
}
and i have imported the http namespace in the app.module.ts like this
import { HttpClientModule } from '@angular/common/http';
and in the imports like this
imports: [
BrowserModule,
FontAwesomeModule ,**HttpClientModule**,
RouterModule.forRoot(appRoutes)
],
and in my component i am using the service like this
trending.component.ts
import { TrendingChannelsService } from './services/TrendingChannelsService';
import { Component, OnInit } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
@Component({
selector: 'trending',
templateUrl: 'trending.component.html',
styleUrls:['osahan.scss','bootstrap.min.scss' ,
'owl.carousel.scss','owl.theme.scss','live.scss','custom.scss','all.min.css' ]
})
export class trending implements OnInit
{
data : any;
constructor(private objchannel : TrendingChannelsService)
{
}
ngOnInit()
{
this.objchannel.GetChannels().subscribe((result: any)=>{
this.data = result;
console.warn("results", this.data);
console.log(result);
} );
}
}
and for some reason i dont see anything logged in the developer console, i used both .log and warn but my browser(Chrome) dont show the returned data. if you can take the URL for the service you will see it will give json data back.
Thanks
Top comments (0)