3
我正在尝试在UI路由器中使用components
(而不是controllers
和templates
)。但是这不起作用。
我跟随this文章从他们的网站。
Plunk
HTML:如何使用ui路由器使用角度组件?
<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>"
});
我没有得到结果,也没有任何错误。我在这里错过了什么?
在此先感谢。
开关的版本,然后单击库[工作正常这里(HTTPS:/ /plnkr.co/edit/Cpph8siwPTnJYf5ihniO?p=preview) – charlietfl