簡體   English   中英

如何使用ui-router的角度組件?

[英]How to use angular component with ui-router?

我試圖在ui-router中使用components (而不是controllerstemplates )。 但這不起作用。
我在他們的網站上關注這篇文章。
普拉克

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>"
});

我既沒有得到結果,也沒有任何錯誤。 我在這里缺少什么?
提前致謝。

你沒有合適的版本。

獲得測試版

npm install --save angular-ui-router@1.0.0-beta.1

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM