[英]How to use angular component with ui-router?
我试图在ui-router中使用components
(而不是controllers
和templates
)。 但这不起作用。
我在他们的网站上关注这篇文章。
普拉克
HTML:
<body ng-app="myApp">
<h1>Help!</h1>
<a ui-sref="mypage">mypage</a>
<ui-view></ui-view>
</body>
JS:
// Register
angular.module('myApp', ['ui.router']);
// config
angular.module('myApp').config(function($stateProvider) {
$stateProvider.state({
name: 'mypage',
url: '/mypage',
component: "newComponent" // cant use this.
})
});
//component
angular.module('myApp').component('newComponent', {
template: "<h1> THis is from component <h1>"
});
我既没有得到结果,也没有任何错误。 我在这里缺少什么?
提前致谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.