1

I read an http link from a JSON file and bind this by using angularjs in my HTML a. The links are intended to be executed on the mobile phone. I'm creating a mobile application with Ionic framework based angularjs

JSON:

 [
    {
      "Name" : "ABC",
      "Address" : "ABC 11",
      "Telephone" : "+1111111",
      "Homepage": "www.google.com",
      "Mail": "test@mail.com"
    }
  ]

HTML:

 <h2>{{item.Name}}</h2>
 <h2>{{item.Address}}</h2>
 <h2><a href="tel:">{{item.Telephone}}</a></h2>
 <h2><a href="url:">{{item.Homepage}}</a></h2>
 <h2><a href="mailto:">{{item.Mail}}</a></h2>

The telephone number and the email address are clickable. if I click on this the telephone number will be called or the mail program will be launched. With the link of website happens nothing. How can I make the link of the Homepage from HTML clickable?

Ramosta
  • 626
  • 1
  • 7
  • 29

1 Answers1

0

You want to use ng-href.

Try something like this:

 <h2>{{item.Name}}</h2>
 <h2>{{item.Address}}</h2>
 <h2><a href="tel:">{{item.Telephone}}</a></h2>
 <h2><a ng-href="{{item.Homepage}}">{{item.Homepage}}</a></h2>
 <h2><a href="mailto:">{{item.Mail}}</a></h2>
MrHaze
  • 3,786
  • 3
  • 26
  • 47
  • I got the error from my chrome browser: `Cannot GET /www.google.com` – Ramosta Jul 29 '15 at 15:05
  • OK. It works. The form of the http link should look like: `http://www.google.com/` It is important to set before the `www` the protokol `http:// ` Thank You – Ramosta Jul 29 '15 at 15:11
  • No worries, happy coding! ;) – MrHaze Jul 29 '15 at 15:11
  • the telephone number, the email address and the web page can be clicked only on the Web browser. If I install the app on the tablet or on the phone, these links are not more clickable. How do I make these links on the devices clickable? for example, when I click on the phone number, the corresponding number should be called. or when the mail address is clicked the mail program should be executed. – Ramosta Aug 03 '15 at 11:17
  • Another problem is the representation of the german character like `ß, ä, ö, ü`. I embedded in my HTML the tag `` but the umlauts like `ä, ü, ö` are not displayed from my JSON file. How could I solve this problem? – Ramosta Aug 03 '15 at 11:18
  • Have a look at HTML5 tags, they wouldn't be a tags As for the second question I wouldn't know off the top of my head – MrHaze Aug 04 '15 at 00:12
  • I have encoded the JSON code with Notepad ++ with UTF-8 section and saved again. Coding problem is solved. But that the links on the device are not clickable, I could not solve so far;) – Ramosta Aug 04 '15 at 12:41
  • check this out http://stackoverflow.com/questions/1608548/how-to-trigger-a-phone-call-when-clicking-a-link-in-a-web-page-on-mobile-phone – MrHaze Aug 04 '15 at 12:43