Angular: How to open angular variable in external browser


#1

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:

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

controller.coffee:

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

(The function is in javascript)

However, I need to open my angular variable {{city.menu.url}}, so this is what I placed in the 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. Appreciate all answers.


#2

You want do a little something like this

#controller in javascript
app.controller("ShowController", function($scope, supersonic){
    $scope.city = {
        menu: { 
            url: 'http://www.google.com'
        }
    };

    $scope.openMenu = function(urlToOpen){
        supersonic.app.openURL(urlToOpen);
    };
});

#template
<button ng-click="openMenu(city.menu.url)">Click here, why not? </button>