1

I want to know if I need to implement this in template tag only

 template: ` <p>Child: {{sharedVar}}</p> 
 <input [(ngModel)]="sharedVar" 
  (ngModelChange)="change()">

...because in my component I have

 @Component({
  selector: 'app-transaction',
  templateUrl: './transaction.component.html',
  styleUrls: ['./transaction.component.scss', ],

  })  

like this. Can I implement it in my html directly

I referred it from -

Angular 2 ngModel in child component updates parent component property

girish_vr
  • 3,041
  • 1
  • 24
  • 27
  • You can't use both `templateUrl` and `template` in same component. You've to use either `templateUrl` or `template`. The difference is in case of`templateUrl`, you write `html template` outside of `.ts` file and in case of `template`, you write `html template` as string inside of `.ts`. Otherwise, there is nothing difference else – Ritwick Dey May 16 '18 at 05:58
  • yes it will work you need to insert it in 'transaction.component.html' and also you have to import import { FormsModule } from '@angular/forms'; – v8-E May 16 '18 at 06:00

1 Answers1

0

No, you can not use both property in one component use either templateUrl or template Beacuse template is inline editing and templateUrl is html page inside editing. So you have to choose one only.

Sanoj_V
  • 2,936
  • 1
  • 12
  • 28