javascript - Ionic: Splitting an <a> tag window.open url to include data -


i trying split url in tag.

inside 1 of templates.html files in ionic, linking externally twitter , facebook.

i using cordova inappbrowser , cut long story short, links twitter , facebook open in correct apps/system browsers... cannot figure out way include data of can use in simple version.

when using:

<a class="twitter" onclick="window.open('https://twitter.com/intent/tweet?text={{offer.title}}%20-%20{{offer.business.data.name}}%20-%20via%20@handle','_system','location=yes');return false;"><i>&#xe12f;</i> twitter</a> 

it opens correctly, not inherit correct data {{offer.title}} , {{offer.business.data.name}} - need way include this.

when using:

<a class="twitter" href="https://twitter.com/intent/tweet?text={{offer.title}}%20-%20{{offer.business.data.name}}%20-%20via%20@handle" target="_system"><i>&#xe12f;</i> twitter</a> 

it loads correct data url, not open correctly @ more of issue - there must way simple:

'url.com/' + {{offer.title}} + '/something' 

or something?

there many ways accomplish this, efficient way handle in angular.js ng-click. following:

var app = angular.module('plunker', []);  app.controller('mainctrl', function($scope) {   $scope.name = 'world';    $scope.offer = {     title: 'sometitle',     business: {       data: {         name: 'some business'       }     }   };    $scope.opentwitter = function(offer) {     window.open('https://twitter.com/intent/tweet?text=' +       offer.title +       '%20-%20' +       offer.business.data.name +       '%20-%20via%20@handle', '_system', 'location=yes');   } }); 

html:

<a ng-click="opentwitter(offer)" href="">open twitter</a> 

http://plnkr.co/edit/tqqwhc0nlp9rpo85asbv


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -