2016-11-04 55 views
3

我已經寫了條件如何使用onClick與angularJs?

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

這裏video_call_url在myController的definded爲$scope.video_call_url = 'http://www.google.com/';

但是當我按一下按鈕我得到一個錯誤video_call_url is not defined.

+0

具有u在控制器注入$範圍是什麼? –

+0

是....................... – lakshay

+0

檢查您是否聲明方法的語法是否正確 –

回答

4

你可以做邏輯控制器:

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

而在你看來

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

謝謝............ ..worked – lakshay

1

你可以使用ng-click,而是採用onclick

ng-click="open(video_call_url)" 

$scope.open = function(url) { 
    //inject $window inside controller. 
    $window.open(url, '_system', 'location=yes'); 
    return false; 
}