import { Component, OnInit } from '@angular/core';
import { RouterModule, Router, ActivatedRoute, RoutesRecognized } from '@angular/router';
import { Http, RequestOptions, Headers } from "@angular/http";
import "rxjs/add/operator/map";
import { Meta, Title } from '@angular/platform-browser';
declare var jQuery:any;
@Component({
selector: 'app-page',
templateUrl: './page.component.html',
styleUrls: ['./page.component.css']
})
export class PageComponent implements OnInit {
public code = '';
public urlar = [];
public data = [];
public keywords = '';
public description = '';
constructor(public meta : Meta, public title: Title, private http: Http, private router: Router) {
router.events.subscribe((val) => {
window.scrollTo(0, 0);
});
this.urlar = location.href.split('/')
this.code = this.urlar[this.urlar.length-1]
let headers = new Headers({ 'Content-Type': 'application/json;charset=utf-8' });
let url = ''
this.http.post(url, {code: this.code}, { headers: headers })
.map(
(response) => response.json()
).subscribe(data => {
this.data = data
if(data != null )
{
this.keywords = data.keywords
this.description = data.description
title.setTitle(data.title)
meta.addTags(
[
{
name : 'keywords', content : this.keywords
},
{
name : 'description', content : this.description
}
]
)
}
});
}
ngOnInit( ) {
}
}