'Call with a button a saved number in another page( IONIC, Angular)

Hi I want to call a number which is saved in another page. I don't know how to explain this well but I put some captures, and the code that I'm trying to use, I just only want to catch the value of the number and put into the button to call. I'm using ionic framework and angular. I'm very new at this but I want to create an app and I'm stuck with this. Sorry for my english is not my native language. Client Detail

Call button

Button page .ts

Detail html page(the first image)

button page html (click) function



Solution 1:[1]

import { ICompanyAddress } from './../interfaces/Map';
import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class SharedDataService {
  _phoneNumber: string;
  constructor() { }

  get phoneNumber(): string {
    return this._phoneNumber;
  }
  set phoneNumber(newValue: string) {
    this._phoneNumber = newValue;
  }
}

Now You could change access its data from any page and changing its value:

example1 (change phoneNumber from a page)

  constructor(private sharedDataService : SharedDataService) {
this.changePhoneNumber()

 }

changePhoneNumber(){

this.sharedDataService.phoneNumber = '12345678'

}

example1 (get last phoneNumber changed value in a page)

constructor(private sharedDataService : SharedDataService) {
  console.log(this.sharedDataService.phoneNumber)// 12345678

}

Solution 2:[2]

For that, you can create services and then store your PhoneNumber in services. Check this out .I hope it will help you.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Zrelli Majdi
Solution 2 DeC