Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

933
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda