我正在尝试在任何调用 URL 上显示一些 View 。
$stateProvider.state('test', {
url: '',
views: {
'testView@' : {
templateUrl: '/app/test/test.html',
controller: 'test.controller',
controllerAs: 'testVM'
}
}
});
我尝试过 url: ''
并且没有 url 属性,但我的 View 从未显示。它仅在具有特定 url(例如 url: '/'
这是我的index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Mock App</title>
<!-- Import additional "vendor" css here -->
<link rel="stylesheet" href="resources/styles/bundle-GENERATED-VERSION.min.css">
</head>
<body>
<h1>Test</h1>
<div data-ui-view="testView"></div>
<script src="app/bundle-GENERATED-VERSION.min.js"></script>
</body>
</html>
我该怎么做?
最佳答案
如果你想匹配每个以/
开头的url
你可以尝试类似url:'/*path'
https://github.com/angular-ui/ui-router/wiki/URL-Routing#regex-parameters
关于javascript - 对于没有 url 的 ui-router 状态, Angular View 不会显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41200771/