I am currently developing a checkout feature that calculates shipping prices based on the selected country. If the user picks United States, it should display US. For any other country selection, it should show Not US
While the shipping function correctly returns US when United States is selected, it still returns US even when another country is chosen.
JS
var app = angular.module("CartApp", ['ngCookies']);
app.controller("CartForm", function ($scope, $cookieStore) {
var shipping = 0;
$scope.shipping = function () {
var e = document.getElementById("countries").value;
if (e == 'United States') {
shipping = 1;
return "US";
} else if (e != 'United States') {
shipping = 4;
return "Not US";
}
};
});
HTML
<div ng-app="CartApp">
<div ng-controller="CartForm">{{shipping()}}
<select id="countries" name="countries">
<option selected="selected" value="United States">United States</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
</select>
</div>
</div>