我正在尝试在 ui-router 中使用 components
(而不是 controllers
和 templates
)。但这不起作用。
我正在关注 this他们网站上的文章。
Plunk
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>"
});
我既没有得到结果,也没有任何错误。我在这里缺少什么?
提前致谢。
最佳答案
关于javascript - 如何在 ui-router 中使用 Angular 组件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39809377/