Naju
Naju

Reputation: 1541

Add a scope variable as a argument for window.open function

I want to add a scope variable as a argument for window.open function, i am using the following code.

onclick="window.open($scope.positionsURL, '_system', 'location=yes'); return false;" 

I am getting the following error.

Uncaught ReferenceError: $scope is not defined

What am I missing? Do I have any syntax error? Please help me to solve this issue.

Upvotes: 1

Views: 547

Answers (1)

Michel
Michel

Reputation: 28259

You should use ng-click instead:

ng-click="open(positionsURL, '_system', 'location=yes')"

And define the function $scope.open in the controller. Should be something like that:

$scope.open = function (url, name, spec) {
    $window.open(url, name, spec);  // don't forget to inject $window in the controller
    return false;
}

Upvotes: 3

Related Questions