angular 1.5.x コンポーネントで Ui-Router (1.0.0-beta.2) を使用しようとしています。
このドキュメントを使用して: https://ui-router.github.io/guide/ng1/route-to-component、私はそのようなものを思いつきました:
config.$inject = ['$stateProvider'];
export default function config($stateProvider) {
$stateProvider
.state('app', {
url: '/app',
component: 'hello'
});
}
こんにちはコンポーネントはそのようなものです:
class Hello {
static component() {
return {
template: 'Hello component !!!'
};
}
}
export default Hello.component();
私のモジュール内で、コンポーネントをインポート/作成します:
import AppConfig from './app.config';
import AppComponent from './app.component';
import HelloComponent from './hello.component';
let appModule = angular.module('demo.app', []);
appModule.config(AppConfig);
appModule.component('app', AppComponent);
appModule.component('hello', HelloComponent);
さて、Ui-Routerで、行を変更component: 'hello'
するtemplate: '<hello></hello>'
と動作します。
ここで何が欠けていますか?
Ui-Router のおかげでデータを解決する必要があるため、テンプレートを使用してコンポーネントを作成したくありませんresolve
。
助けてくれてありがとう!
編集 1:プロジェクトは Github で見つけることができます: https://github.com/maxime1992/web-template-webpack/tree/component-router
ルーターはここで定義されます