Angular 将指令延迟加载到页面中的组件中
我有一个使用组件的页面,在该组件的模板中我称之为指令。我已将该指令导入到添加到page.module设置的共享模块中。但该指令未在组件上注册。我怎样才能让它工作呢 页面->组件->指令 共享模块:Angular 将指令延迟加载到页面中的组件中,angular,ionic2,lazy-loading,Angular,Ionic2,Lazy Loading,我有一个使用组件的页面,在该组件的模板中我称之为指令。我已将该指令导入到添加到page.module设置的共享模块中。但该指令未在组件上注册。我怎样才能让它工作呢 页面->组件->指令 共享模块: import { NgModule } from '@angular/core'; /** Directives **/ import { CallDirective } from '../directives/call/call'; import { NavigateDirective } from
import { NgModule } from '@angular/core';
/** Directives **/
import { CallDirective } from '../directives/call/call';
import { NavigateDirective } from '../directives/navigate/navigate';
import { OpenLinkDirective } from '../directives/open-link/open-link';
import { ShareDirective } from '../directives/share/share';
import {UserBookingsDirective} from '../directives/user-bookings/user-bookings'
import {BookingCommentDirective} from '../directives/booking-comment/booking-comment'
/** Pipes **/
import { LimitToPipe } from './../pipes/limit-to/limit-to';
import { SearchPipe } from './../pipes/search/search';
@NgModule({
declarations: [
CallDirective,
NavigateDirective,
OpenLinkDirective,
ShareDirective,
UserBookingsDirective,
BookingCommentDirective,
LimitToPipe,
SearchPipe
],
exports:[
CallDirective,
NavigateDirective,
OpenLinkDirective,
ShareDirective,
UserBookingsDirective,
LimitToPipe,
SearchPipe
],
imports: [
],
})
export class SharedModule {}
页面模块:
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { BookingsPage } from './bookings';
import { MomentModule } from 'angular2-moment';
import {SharedModule} from '../../app/shared.module';
/** Components **/
import {BookingItemComponent} from '../../components/booking-item/booking-item'
@NgModule({
declarations: [
BookingsPage,
BookingItemComponent
],
imports: [
IonicPageModule.forChild(BookingsPage),
MomentModule,
SharedModule
],
})
export class BookingsPageModule {}
将
BookingCommentDirective
添加到exports:[…]
,以使其可用于导入模块:
@NgModule({
declarations: [
CallDirective,
NavigateDirective,
OpenLinkDirective,
ShareDirective,
UserBookingsDirective,
BookingCommentDirective,
LimitToPipe,
SearchPipe
],
exports:[
BookingCommentDirective, // <<== added
CallDirective,
NavigateDirective,
OpenLinkDirective,
ShareDirective,
UserBookingsDirective,
LimitToPipe,
SearchPipe
],
imports: [
],
})
export class SharedModule {}
@NgModule({
声明:[
调用指令,
导航导向,
OpenLinkDirective,
共享指令,
UserBookingsDirective,
预订指令,
有限管道,
探照管
],
出口:[
BookingCommentDirective,//请显示如何“导入”代码指令。我已经添加了用于导入模块的代码,在那里你可以看到我已将该指令导入共享模块。编辑显示如何使用该组件和指令的代码也会很有帮助。从可用的代码来看,不清楚你指的是什么组件或指令。BookingCommentDirective我想使用在组件BookingItemComponent中的元素上。