[英]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.