Ramosta
Ramosta

Reputation: 647

Making http link clickable from JSON file

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": "[email protected]"
    }
  ]

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?

Upvotes: 1

Views: 2406

Answers (1)

MrHaze
MrHaze

Reputation: 3996

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>

Upvotes: 0

Related Questions