I have app.component like below
/*//
import { Component } from '@angular/core';
import { DndComponent } from './dnd/dnd.component';
@Component({
selector: 'app-root',
template: ' (click)="sample()"',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
constructor(public ob:DndComponent) {
}
sample(){
this.ob.changevar();
}
}
/*//
And, I have another dnd component like
/*//
import { Component } from '@angular/core';
@Component({
selector: 'dnd',
template: '<div>{{name}}</div>',
styleUrls: ['../app.component.css']
})
export class DndComponent {
name:string="saran"
constructor(){
}
changevar(){
this.name="kumar";
}
}
/*//
here, I am trying to change the name value with method calling from another component. The name value is updating but the view is not rendering.
is there any way to render the other component view dynamically with an on-click method from another component.
Thanks,