简体   繁体   English

角度:如何在外部浏览器中打开角度变量-Appgyver Hybrid App

[英]Angular: How to open angular variable in external browser - appgyver hybrid app

How do I add an angular variable into my controller function? 如何在控制器功能中添加角度变量? I want to open links in my mobile app in external browser. 我想在外部浏览器的移动应用程序中打开链接。

This currently works for me: 目前,这对我有用:

html: 的HTML:

<button ng-click="openMenu()">Menu</button>

controller.coffee: controller.coffee:

.controller("ShowController", ($scope, City, supersonic) ->
    $scope.openMenu = function($scope) {
supersonic.app.openURL(“https://www.google.com“);
};

(The function is in javascript) (该功能在javascript中)

However, I need to open my angular variable {{city.menu.url}}, so this is what I placed in the html. 但是,我需要打开角度变量{{city.menu.url}},所以这就是我在html中放置的内容。

<button ng-click="openMenu(city.menu.url)">Menu</button>

But I don't know how to orient the javascript so that the supersonic.app.openURL opens the variable I specified in the html. 但是我不知道如何定向javascript,以便supersonic.app.openURL打开我在html中指定的变量。 Appreciate all answers. 欣赏所有答案。

Change this supersonic.app.openURL(“https://www.google.com“); 更改此supersonic.app.openURL(“https://www.google.com“); with: 与:

$window.location.href = 'http://www.google.com';

Inject $window in the controller 在控制器中注入$window

.controller("ShowController", ($scope, $window, City, supersonic) ->
    $scope.openMenu = function(url) {
        $window.location.href = url; //'http://www.google.com';
    };

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM