【发布时间】:2017-06-24 04:02:37
【问题描述】:
当我输入http://localhost:6060/home时,它显示我无法获取/home,但是当我单击按钮$state.go('home')时,它显示,并且URL仍然是http://localhost:6060/home。但是当我刷新时,它仍然没有显示。输入网址时如何显示?
这是我的代码:
路由器.js
$stateProvider.state("home", {
url: "/home",
template: "<h2>I am a router test</h2>"
});
$locationProvider.html5Mode(true);
index.html
<head>
<title>for test</title>
<base href="/">
</head>
<body ng-app="my.module">
<h1>I am just a test</h1>
<div ng-controller="test"><button class="btn btn-default"
ng-click="testclick()">click me</button></div>
<ui-view></ui-view>
</body>
控制器:
$scope.testclick = function () {
$state.go('home');
};
如果我不使用$locationProvider.html5Mode(true); 并且没有设置base 标签,我必须输入localhost:6060/#!/home。 ! 是什么意思?
【问题讨论】:
-
您可以添加您的
.config()代码吗?
标签: javascript angularjs angular-ui-router