Reputation: 433
I am trying to add a dynamic link to an href in Angular/Ionic but the below is not working. I had an "onclick before the ng-click" as the expression {{post.id}} was not loading.
<a class="w-inline-block post-block-link" href="" ng-click="window.open('http://www.example.com/#/post/{{post.id}}', '_blank', 'location=no'); return false;" data-ix="press" ng-repeat="post in postList">
Upvotes: 1
Views: 598
Reputation: 7418
HTML
<a ng-click="openWindow(post)" ng-repeat="post in postList"></a>
JavaScript
yourApp.controller('yourController', function($scope) {
$scope.openWindow = function(post) {
var url = 'http://www.example.com/#/post/' + post.id;
window.open(url, '_blank', 'location=no');
}
});
Upvotes: 4