angularjs - 如何在 angularJs 中使用 onClick?

标签 angularjs

我写了条件

onclick="window.open({{video_call_url}}, '_system', 'location=yes'); return false;"
这里video_call_url在 Controller 中定义为 $scope.video_call_url = 'http://www.google.com/';但是当我点击按钮时,我收到一个错误 video_call_url is not defined.

最佳答案

您可以在 Controller 中执行逻辑:

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

在你看来
<a ng-click="openVideoCallUrl()">Open!</a>

关于angularjs - 如何在 angularJs 中使用 onClick?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40421822/

相关文章:

javascript - 在 angularjs 数组中使用切片

javascript - 如何在单击 ionicActionSheet 选项时打开 ionicPopup?

javascript - 将保存时间戳的 ng-model 绑定(bind)到 datetime-local 输入

javascript - CellFilter 在 UI-Grid 中的 $http 响应之前被调用

javascript - 如何解析包含 HTML 标记的范围字段

javascript - TypeScript:替换现有类型

javascript - 发布和订阅同一主题的 mqtt 最佳实践

javascript - 如何在指令测试中注入(inject)服务

jquery - 在 angularJS Controller 中使用 jQuery 的 $.ajax

javascript - 使用指令 Angular JS 动态更改文本的颜色