2

Why doesn't this work?

<a ng-click="if(item.lp_iframe=='') ? href='{{item.lp_url}}' :
             playVideo(item.lp_iframe_id)" target="_blank">

I suspect I have to escape the ''??

1
  • 2
    what is the error statement that you getting in the console? Commented Feb 26, 2014 at 4:11

2 Answers 2

2

move this to a function in scope, like this

$scope.foo = function() {
  // ...
}

ng-click="foo()"

According to the doc.

ng-click="expression" 

Expression doesn't mean javascript, see http://docs.angularjs.org/guide/expression.

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

1 Comment

@user3346088 why playVideo will cause problem? call it like playVideo(...) or $scope.playVideo(...).
0

Your problem is, your expression look like

<a>ng-click="href='url'"></a> // is the syntax is correct? Not

So try this

<a ng-click="if(item.lp_iframe=='') ? redirect(item.lp_url) :
             playVideo(item.lp_iframe_id)" target="_blank">

   $scope.redirect= function(url) { 
      window.open(url)  
    }

or,

Try this

<a ng-click="clickevent()" target="_blank">

$scope.clickevent= function() {
  if(item.lp_iframe=='') 
       {   
        window.open(url)
       }
        playVideo(item.lp_iframe_id)
    }

15 Comments

$location is not defined
you need assign the $location in your controller
Object #<Object> has no method 'reload'
it make perfect sense but I gt an erorr, what does the reload do? and return true?
Sorry change that to $route.reload();
|

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.