0
votes

I have written a variable named 'test', inside child component ts file. value of test will be updated from child component view. I have to access 'test' variable in parent component.. pls help...

1

1 Answers

0
votes

Shared service seems to be what you need. Take a look at this answer here: shared service You would make a shared service like in that answer, where you share test and can access it from components you need :)

@Injectable()
export class YourSharedService {
    sharedTest: {
        testString: 'your value here'
    };
}

and then inject it in your constructor and access it in your components:

constructor(private yourSharedService: YourSharedService) {  }

testString = this.yourSharedService.sharedTest

and as Suraj commented, just check the link he provided, there are some tips for solutions.