<body>
<p ui-view></p>
<a ui-sref="test">点击</a>
</body>
<script type="text/javascript">
var app = angular.module('myApp', ['ui.router']);
app.config(function($stateProvider, $urlRouterProvider){
$stateProvider
.state("test", {
url: '/test',
template:'<p>你好</p>',
});
});
</script>
Click the a tag, ui-view displays "Hello", click the browser to go back and "Hello" still exists on the page, why is this?
It is recommended to read this article first about using angular-ui-router. By default, an initial state needs to be set. See the following usage examples for details.