1

我正在尝试将 Ui-Router (1.0.0-beta.2) 与 Angular 1.5.x 组件一起使用。

使用这个文档: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

路由器在这里定义

4

0 回答 0