3

I have a AngularJs Application in which I want to pass scope variable to onclick="window.open('{{portfolio.link}}', '_system');"

My Code :

<a class="item item-avatar txtShow" onclick="window.open('"{{portfolio.link}}"', '_system');" ng-repeat="portfolio in freelancer.portfolio">
  <img class="portfoliobg" src="{{portfolio.image}}">
  <h2>{{portfolio.name}}</h2>
  <p>{{portfolio.description}}</p>
  <h5>Added On :{{portfolio.adddate}}</h5>
</a>

Here my angularJS variable is not working and its taking it as simple text

1
  • 1
    Why do you try to write onClick method implementation into HTML? It makes difficult to maintenance And why not ng-click (if you use Angular)? Commented Jul 23, 2014 at 13:58

1 Answer 1

3

Ran into a similar problem and ended up using a function in my controller to make it work.

    <a class="item item-avatar txtShow" ng-click="openPortfolioURL()">
  <img class="portfoliobg" src="{{portfolio.image}}">
  <h2>{{portfolio.name}}</h2>
  <p>{{portfolio.description}}</p>
  <h5>Added On :{{portfolio.adddate}}</h5>
</a>

Then in the controller:

$scope.openPortfolioURL = function() {
    try {
        var portfolioURL = $scope.portfolio.link;
        window.open(portfolioURL, '_system');
    } catch (err) {
        alert(err);
    }
}

Credit to the Ionic forums.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.