角度2组件未显示

pro*_*007 14 typescript ionic2 angular

我想OAuthComponent在我的GettingStartedPage组件中显示一个.在OAuthComponent当提供给我的浏览器没有显示出来.没有错误.

OAuthComponent.ts

import {Page, NavController} from 'ionic/ionic';
import {Component} from 'angular2/angular2'

@Component({
    templateUrl: "app/authentication/components/oauth-component.html",
    selector: "oauth-component"
})
export class OAuthComponent {

    private nav: NavController;

    constructor(nav: NavController) {
        this.nav = nav;
    }
}
Run Code Online (Sandbox Code Playgroud)
oauth-component.html

<h1>
    Testing Something
</h1>
Run Code Online (Sandbox Code Playgroud)
GettingStartedPage.ts

import {Page, NavController} from 'ionic/ionic';
import {OAuthComponent} from "../authentication/components/OAuthComponent";
import "./getting-started.scss";

@Page({
    templateUrl: 'app/getting-started/getting-started.html',
    directives: [OAuthComponent]
})
export class GettingStartedPage {

    private nav: NavController;

    constructor(nav: NavController) {
        this.nav = nav;
    }
}
Run Code Online (Sandbox Code Playgroud)
getting-started.html

<ion-navbar *navbar>
    <a menu-toggle>
        <icon menu></icon>
    </a>

    <ion-title>Getting Started</ion-title>
</ion-navbar>

<ion-content>
    <main>
        <oauth-component></oauth-component>
    </main>
</ion-content>
Run Code Online (Sandbox Code Playgroud)

Nem*_*vić 9

Angular2中的所有组件都必须引用视图中显示的其他组件.

Ionic似乎用他们自己的@Page注释来处理这个问题,但它只涵盖了Ionic特定的组件.decorators.ts解释了这种行为.

您需要编辑代码以包含OAuthComponentdirectives:

@Page({
    templateUrl: 'app/getting-started/getting-started.html',
    directives: [OAuthComponent] // Don't forget to import it
})
export class GettingStartedPage {
Run Code Online (Sandbox Code Playgroud)