I am using angular 4 in my application and I wanted to use a reusable component which helps me to display some information dynamically based on the user. So as a first step I have created component!.
import { Component, OnInit, Input } from '@angular/core';
import {Router} from '@angular/router';
@Component({
selector: 'pageInfo',
templateUrl: './pageInfo.component.html',
styleUrls: ['./pageInfo.component.scss']
})
export class PageInfoComponent implements OnInit {
public info: string;
public manipulatedString: string;
constructor() {
}
ngOnInit() {
}
stringManipulation(){
this.manipulatedString = "" // Some sort of manipulation using this.info string value
}
}
Now I will start using <pageInfo></pageInfo>
tag in some other html pages, while using I want to pass some hard coded string value into PageInfoComponent class through Component selector. After getting string value PageInfoComponent class will manipulate it and add some sort of styles and the result will be displayed.
pageInfo.component.html
<div>{{manipulatedString}}</div>
So how can I pass string value from component selector to it's class, so that I can display manipulated string with reusable component.