app.js.txt -------- var countryApp = angular.module("countryApp", ["ngRoute"]); countryApp.config(function ($routeProvider) { $routeProvider .when("/", { templateUrl: "country-list.html", controller: "CountryListController", }) .when("/:countryName", { templateUrl: "country-detail.html", controller: "CountryDetailController", }) .otherwise({ redirectTo: "/", }); }); countryApp.controller("CountryListController", function ($scope, $http) { var proxyUrl = "https://cors-anywhere.herokuapp.com/"; var targetUrl = "http://www.bogotobogo.com/AngularJS/files/Route2/countries.json"; $http .get(proxyUrl + targetUrl) .then(function (response) { $scope.countries = response.data; }) .catch(function (error) { console.error("Error fetching countries:", error); }); }); countryApp.controller( "CountryDetailController", function ($scope, $routeParams, $http) { var countryName = $routeParams.countryName; var proxyUrl = "https://cors-anywhere.herokuapp.com/"; var targetUrl = "http://www.bogotobogo.com/AngularJS/files/Route2/countries.json"; $http.get(proxyUrl + targetUrl).then( function (response) { var countries = response.data; $scope.country = countries.find(function (country) { return country.name === countryName; }); }, function (error) { console.error("Error fetching country details:", error); } ); } ); index.htm.txt --------