Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

934
Visualizações
send whatsapp message from angular 2 web app

Building a web app using angular 2, (or 4). Want to send a message through whatsapp. This works fine whatsapp://send?text=hi! to open whatsapp from the browser. I want to send the url of the current page. I can use {{url}} to print the url on the web page but I don't know how to set text={{url}} if you know what I mean.

relevant part of the component `

export class ActivityDetailsComponent implements OnInit {


  @Input() activity: any;
  @Output() close = new EventEmitter();
  error:any;
  navigated = false;
  sub: any;
  imageURL: string;
  location:Location;
  url: any;

  constructor(private activitiesService:ActivitiesService,
                private route: ActivatedRoute,
                private router: Router,
                private pics: PicsService,
                location:Location             

                ) { 

                this.location = location;
                this.url = this.location.path();

                 }

`

relevant html `

    Send a link to this activity to your
     <a href="whatsapp://send?text=http://ec2-52-209-95-130.eu-west-  
 1.compute.amazonaws.com:4200/activities/58c003d47513092fac820f09">whatsapp</a>
     contacts  

    http://ec2-52-209-95-130.eu-west-1.compute.amazonaws.com:4200{{url}}

`

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

There are two possible techniques to solve your problem:

  1. Property binding

We use square brackets to tell angular to resolve the value of the href field. Additionally we use simple string concatenation:

<a [href]="'http://example.org/?test=' + url">whatsapp</a>
  1. Interpolation

This is technique uses the curly brackets and is the one you tried to use:

  <a href="{{'http://example.org/?test=' + url}}">whatsapp</a>

In your case you can chose the solution you prefer, the official documentation (same link as above) states the following:

When rendering data values as strings, there is no technical reason to prefer one form to the other. You lean toward readability, which tends to favor interpolation. You suggest establishing coding style rules and choosing the form that both conforms to the rules and feels most natural for the task at hand.

over 4 years ago · Santiago Trujillo Relatório

0

Use the following code to do it

var url = document.URL var red = (url.substr(url.lastIndexOf('=') + 1)); window.location.replace("https://api.whatsapp.com/send?text=" + red);

Or you can use the permanent link below to go directly without any script

https://www.educlick.page/p/whats-app-redirect.html?url>url encode<

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda