In this plunk I have a ui-router $state.goto that only works the first time, even though I'm incrementing a seq variable to force the reload. See that the time stamp doesn't change. What's wrong with this code?
HTML
<body ng-controller="MyCtrl">
<button ng-click="goto()">Go to state</button>
<div ui-view=""></div>
</body>
State HTML
<div>
{{time1}}
</div>
Javascript
var app = angular.module("app", ['ui.router']);
app.controller('MyCtrl', function($scope,$state) {
var seq = 0;
$scope.goto = function(){
alert('about to go to state - ' + seq) ;
var params = {
seq: seq++
};
$state.go ( 'state1', params );
};
});
app.controller('state1Ctrl', function($scope) {
$scope.time1 = new Date();
});
app.config(function($stateProvider) {
$stateProvider
.state('state1', {
templateUrl: 'state1.html',
controller: 'state1Ctrl'
});
});