简体   繁体   English

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

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

I am trying to use components (instead of controllers and templates ) in ui-router. 我试图在ui-router中使用components (而不是controllerstemplates )。 But this isn't working. 但这不起作用。
I'm following this article from their website. 我在他们的网站上关注这篇文章。
Plunk 普拉克

html: HTML:

  <body ng-app="myApp">
    <h1>Help!</h1>
    <a ui-sref="mypage">mypage</a>
    <ui-view></ui-view>
  </body>

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

I'm neither getting the result, nor any errors. 我既没有得到结果,也没有任何错误。 What I'm missing here? 我在这里缺少什么?
Thanks in advance. 提前致谢。

You don't have the right version. 你没有合适的版本。

Get the beta one : 获得测试版

npm install --save angular-ui-router@1.0.0-beta.1 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