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.
the Angular 2 onClick Event The Angular 2 event system can be used to handle different types of events, such as mouse clicks, keyboard presses, and touch gestures. The onclick event triggers an event or function when a user clicks on a component or an element.
The ng-click Directive in AngluarJS is used to apply custom behavior when an element is clicked. It can be used to show/hide some element or it can pop up an alert when the button is clicked. Parameter Value: expression: It specifies when the particular element is clicked then the specific expression will be evaluated.
For a single btn, it's ok to use ng-click or onclick in the ng-app . There is no difference between the two functions. For effective team work, you,d better to have an account with each other. In Angular apps, ng-click is recommended.
Syntax of using ng-click directive There, the button is an element that can be replaced by any other HTML element like a link, span, paragraph, div etc.
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>
You could use ng-click
, instead of using onclick
ng-click="open(video_call_url)"
$scope.open = function(url) {
//inject $window inside controller.
$window.open(url, '_system', 'location=yes');
return false;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With