I would like to create a drop down redirect page in angular JS. Where in when a user selects the drop down and then clicks Go button he is directed to the page.
below is the angularJS script, with a little Javescript and the Html page.
//Angular JS
function TheController($scope) {
$scope.locations = [
{LocationId : "http://www.google.com/", LocationName : 'Philippines' },
{LocationId : " http://www.yahoo.com/" , LocationName : 'Canada' },
{LocationId : " http://www.bing.com/", LocationName : 'China' } ];
function goToNewPage(dropdownlist)
{
var url = dropdownlist.options(dropdownlist.selectedIndex).value;
if (url != "")
{
window.open(url);
}
}
}
//Html
<form name="dropdown">
<div ng-controller="TheController" ng-app>
Another Location:
<select ng-model="anotherLocationId" onchange="goToPage(this.options(this.selectedIndex).value)" >
<option ng-repeat="location in locations" value="{{location.LocationId}}">{{location.LocationName}}</option>
</select>
<hr/>
Another Location: {{anotherLocationId}}
</div>
<input type=button value="Go" onclick="goToNewPage(document.dropdown.list)">
</form>