首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用ng-bootstrap解析模板错误

使用ng-bootstrap解析模板错误
EN

Stack Overflow用户
提问于 2019-04-11 02:47:59
回答 1查看 3.9K关注 0票数 1

我收到错误消息

代码语言:javascript
复制
Uncaught Error: Template parse errors:
There is no directive with "exportAs" set to "ngbAccordion" ("
    <p *ngIf="spinner" class="text-center margin-100">Loading...</p>

    <ngb-accordion [ERROR ->]#acc="ngbAccordion" activeIds="ngb-panel-0">
      <ngb-panel title="Simple">
        <ng-template "): ng:///SurveysModule/SurveysComponent.html@4:19
'ngb-panel' is not a known element:
1. If 'ngb-panel' is an Angular component, then verify that it is part of this module.
2. If 'ngb-panel' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("

    <ngb-accordion #acc="ngbAccordion" activeIds="ngb-panel-0">
      [ERROR ->]<ngb-panel title="Simple">
        <ng-template ngbPanelContent>
    <table class="table table-bord"): ng:///SurveysModule/SurveysComponent.html@5:6
'ngb-accordion' is not a known element:
1. If 'ngb-accordion' is an Angular component, then verify that it is part of this module.
2. If 'ngb-accordion' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
    <p *ngIf="spinner" class="text-center margin-100">Loading...</p>

基于此代码

代码语言:javascript
复制
  <section>
    <p *ngIf="spinner" class="text-center margin-100">Loading...</p>

    <ngb-accordion #acc="ngbAccordion" activeIds="ngb-panel-0">
      <ngb-panel title="Simple">
        <ng-template ngbPanelContent>
    <table class="table table-bordered" *ngIf="surveyFormData.length">
        <thead>
        <tr>
            <th scope="col">Form Type</th>
            <th scope="col" class="width-110">Registry Type</th>
            <th scope="col" class="width-70">Version</th>
            <th scope="col" class="width-150">Published Status</th>
            <th scope="col" class="width-100">Active Status</th>
            <th scope="col" class="width-260 text-center">Actions</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let form of surveyFormData">
            <th scope="row">{{ form.FormType }}</th>
            <th scope="row">{{form.RegistryID | registryType}}</th>
            <th scope="row">{{form.Version }}</th>
            <th scope="row">{{form.IsPublished ? 'Published' : 'Unpublished'}}</th>
            <th scope="row">{{form.IsActive ? 'Active' : 'Inactive'}}</th>
            <td class="text-nowrap">
                <a href="javascript:;" (click)="exportSpecs(form)" title="Export Specs" class="record-action">
                    <i class="material-icons">input</i>
                    <span>Export Specs</span>
                </a>
                <a href="javascript:;" (click)="publishForm(form)" title="Publish" class="record-action" [class.disabled]="form.IsPublished">
                    <i class="material-icons">publish</i>
                    <span>Publish</span>
                </a>

                <a href="javascript:;" (click)="confirmFormActivation(form)" title="Activate" class="record-action" [class.disabled]="form.IsActive">
                    <i class="material-icons">toggle_on</i>
                    <span>Activate</span>
                </a>

                <a routerLink="/records/playground/{{form.FormType}}/{{form.Version}}" title="View form in Playground"
                   class="record-action">
                    <i class="material-icons">visibility</i>
                    <span>View</span>
                </a>
                <a routerLink="/survey-builder/{{form.FormType}}/{{form.RegistryID}}/{{form.Version}}"
                   title="Edit Survey" class="record-action">
                    <i class="material-icons">create</i>
                    <span>Edit</span>
                </a>
            </td>
        </tr>
        </tbody>
    </table>
  </ng-template>
</ngb-panel>
</ngb-accordion>

</section>

我以为我没看错https://ng-bootstrap.github.io/#/components/accordion/examples

似乎已正确安装并包含在导入中

代码语言:javascript
复制
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';


@NgModule({

    declarations: [
        AppComponent
    ],
    imports: [
        NgbModule,
EN

Stack Overflow用户

回答已采纳

发布于 2019-04-11 02:56:13

Angular组件是模块范围的,所以我的建议是在SurveysModule中导入NgbModule

代码语言:javascript
复制
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';


@NgModule({
    ...
    imports: [
        NgbModule,
    ]
})
export class SurveysModule {}
票数 5
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55619440

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档