0

どのように使用できます[router-link][inner-html]

例は次のとおりです。

    import {Component, View} from 'angular2/angular2';
    import {RouterLink, ROUTER_DIRECTIVES} from 'angular2/router';

    @Component({
        selector: 'index'
    })
    @View({
        template: `
            <div> Index Content </div>
            <div [inner-html]="test"></div>
        `,
        directives: [ROUTER_DIRECTIVES]
    })

    export class Index {
        private test: String;

        constructor() {
            this.test = `<a [router-link]="['/aRoute', 'AComponent']">Test</a>`;
        }
    }

Angular1 http://plnkr.co/edit/F91xvGHBASvqCGBJcEYY?p=previewのソリューションは次のとおりです。

Angular2 でどうすればできますか?

4

1 に答える 1

2

私は解決策を見つけました。

DynamicComponentLoader.loadAsRoot はその問題を解決します。

API は次のとおりです: https://angular.io/docs/ts/latest/api/core/DynamicComponentLoader-class.html

記事もあります: https://medium.com/tixdo-labs/angular-2-dynamic-component-loader-752c3235bf9#.qkxk36s98

編集: DynamicComponentLoader は非推奨です。別の解決策があります: https://stackoverflow.com/a/37044960/5022904

于 2016-03-31T12:58:09.800 に答える