I am trying to use a shared html in the basic angular4 page, i want to use a tag
<search-items (search)="filter($event,'q')"></search-items>
which should display a text box of search option.
what should i do to remove my errors?
I am trying to use a shared html in the basic angular4 page, i want to use a tag
<search-items (search)="filter($event,'q')"></search-items>
which should display a text box of search option.
what should i do to remove my errors?
Try this code yourself : This is your app.ts
//our root app component
import {Component, NgModule, VERSION} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
import {SearchComponent} from 'search.ts'
import {FormsModule } from '@angular/forms'
@Component({
selector: 'my-app',
template: '
<div>
<h2>Hello {{name}}</h2>
<search-items (search)="filter($event,'q')"></search-items>
</div>',
declare:[SearchComponent]
})
export class App {
name:string;
constructor() {
this.name = `Angular! v${VERSION.full}`
}
filter(text:string,text2:string){
console.log("hi")
}
}
@NgModule({
imports: [ BrowserModule , FormsModule],
declarations: [ App , SearchComponent ],
bootstrap: [ App ]
})
export class AppModule {}
2nd fix was in search.ts : your search.html was misspelled as search.component.html
Note : Do import FormsModule from @angular/forms whenever you use ngModel in your code
In addition to Aakash Uniyal's answer here is the new plnkr with the issue resolved.
You also needed to import FormsModule
`import { FormsModule } from '@angular/forms'`