I started to create a single page application that takes the input from a text box and shows up to another page. On the second page I wanted to create a home button that takes me to the original view but also refreshes the application the input box to a blank state.
first view
<input type="text" id="Bad" style="text-transform:uppercase" ng-model="name" />
second view
<h3>Hello</h3>
<span ng-bind="name"></span></br>
<a href="#" ng-click="reload()">
<img src="Home_Icon.png" height="92" />
</a>
app .js controllers
var myApp = angular.module('myApp', ['ngRoute']);
myApp.config(function ($routeProvider) {
$routeProvider.when('/second', {
templateUrl: 'pages/second.html',
controller: 'secondController'
});
});
controller fuunction
myApp.controller('secondController', [
'$scope',
'$log',
'$routeParams',
'$window',
'nameService',
function ($scope, $log, $routeParams, nameService) {
$scope.num = $routeParams.num || 1;
$scope.name = nameService.name;
$scope.$watch('name', function () {
nameService.name = $scope.name;
});
$scope.reload = function () {
location.reload();
}
}]
);
I have tried How to reload a page using Angularjs?. as well. Please Help!. Thanks