When I click on the Home link, the goTo function is executed. However, it redirects me to a blank page like so:
When I click on the browser's back button, it redirects me to the page I wanted to go to (firstPage).
Any suggestions on what I am doing wrong?
HTML:
<footer ng-controller = "footerLink"> <a href = "#" ng-click="goTo('/firstPage')"> Home </a> <a href = "#"> About us </a> <a href = "#"> Our Team </a> <a href = "#"> Blog </a> <a href = "#"> Services </a> <a href = "#"> Portfolio </a> <a href = "#"> Contact </a> <a href = "#"> Sitemap </a> </footer> JS
angular.module('myApp.view1', ['ngRoute']) .config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { $routeProvider. when('/view1', { templateUrl: 'view1/view1.html', controller: 'View1Ctrl' }). when('/buttonView', { templateUrl: 'buttonView/buttonView.html', controller: 'buttonViewCtrl' }). when('/firstPage', { templateUrl: 'view2/view2.html', controller: 'footerLink' }). when('/home', { templateUrl: 'view1/view1.html', controller: 'logo' }); }]) .controller('footerLink', ['$scope', '$location', function($scope, $location) { $scope.goTo = function (url) { $location.path(url); }; }]) UPDATE
I directly redirected the anchor to the firstPage route instead of calling another function. Here is what I changed to make it work:
<footer ng-controller = "footerLink"> <a href = "#/firstPage"> Home </a> <a href = "#"> About us </a> <a href = "#"> Our Team </a> <a href = "#"> Blog </a> <a href = "#"> Services </a> <a href = "#"> Portfolio </a> <a href = "#"> Contact </a> <a href = "#"> Sitemap </a> </footer> 
