0

Sorry if this is a duplicate question, as I could not found any solutions elsewhere in web, so am posting this in StackOverflow

I have referred the duplicated question solutions in StackOverflow, I could not get any solutions for my question, as the solutions available in Stackoverflow are using two components, but am using single component.

My Problem

Am creating an angular 2 components, in which am having a @input to get the value of the selector attribute, if I do console.log of the @input am getting undefined as value

Component

import { Component,Input, OnInit } from '@angular/core';
@Component({
  selector: 'app-root',
  template: ' <p>{{urlinput}}</p>'
})
export class AppComponent implements OnInit{
   @Input() urlinput;  
    ngOnInit() {console.log('value: ' + this.urlinput);}
}

index.Html

<app-root [urlinput]="hello">Loading...</app-root>

Please do correct the code if any this wrong, Thanks in advance

balajivaishnav
  • 2,795
  • 4
  • 23
  • 38

0 Answers0