lakshay lakshay - 1 month ago 7
AngularJS Question

How to use onClick with angularJs?

I have written a condition

onclick="window.open({{video_call_url}}, '_system', 'location=yes'); return false;"


here
video_call_url
is definded in myController as
$scope.video_call_url = 'http://www.google.com/';


but when i click the button i am getting an error
video_call_url is not defined.

Answer

You can do the logic in the controller:

function myController($scope, $window) {
    $scope.openVideoCallUrl = function() {
        $window.open($scope.video_call_url, "_system", "location=yes");
        return false;
    }
}

And in your view

<a ng-click="openVideoCallUrl()">Open!</a>