[英]Angular - Why won't my ui-view show my template html text?
I wonder why my template which I refer to in my angular state ('home') won't be shown - in my index.html I included a <ui-view></ui-view>
tag. 我不知道为什么我的模板在我的角度状态(“ home”)下不会显示-在我的index.html中,我包含了
<ui-view></ui-view>
标记。 Does anyone know? 有人知道吗?
app.js: app.js:
var app = angular.module('portfolio', ['ui.router']);
html: 的HTML:
<body ng-app="portfolio">
<p>hellooooo</p>
<ui-view></ui-view>
<script src="angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/1.0.0-beta.2/angular-ui-router.js"></script>
<script src="js/app.js"></script>
<script src="js/home/home.js"></script>
</body>
home.js: home.js:
app.config(function ($stateProvider) {
$stateProvider.state('home', {
url: '/',
templateUrl: '/browser/js/home/home.html'
});
});
home.html: home.html:
<div><p>not working</p></div>
I think your router are not able to match /
url. 我认为您的路由器无法匹配
/
url。 That's why you have to specify a default state, because not always your url will come with /
. 这就是为什么您必须指定默认状态的原因,因为并非总是url都带有
/
。
Consider forcing a default state like so: 考虑强制这样的默认状态:
$stateProvider.otherwise('/');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.