【问题标题】:ng2-bootsrap has no exported member 'TAB_DIRECTIVES'ng2-bootstrap 没有导出成员 'TAB_DIRECTIVES'
【发布时间】:2016-01-15 09:19:43
【问题描述】:

我正在研究 angular2 i,我必须将标签用于 ui。为此我尝试使用插件http://valor-software.github.io/ng2-bootstrap/

我写了一个demoComponent

    import { Component, View, Inject} from 'angular2/core';
    import { CORE_DIRECTIVES } from 'angular2/common';
    import { TAB_DIRECTIVES } from 'ng2-bootstrap/ng2-bootstrap';

    // webpack html imports
    let template = require('./tabs-demo.html');

    @Component({
      selector: 'tabs-demo',
      template: template,
      directives: [TAB_DIRECTIVES, CORE_DIRECTIVES]
    })
    export class TabsDemo {
      private tabs:Array<any> = [
        {title: 'Dynamic Title 1', content: 'Dynamic content 1'},
        {title: 'Dynamic Title 2', content: 'Dynamic content 2', disabled: true}
      ];

      private alertMe() {
        setTimeout(function () {
          alert('You\'ve selected the alert tab!');
        });
      };
    }

这是我的模板

<div (click)="$event.preventDefault()">
  <p>Select a tab by setting active binding to true:</p>
  <p>
    <button type="button" class="btn btn-primary btn-sm" (click)="tabs[0].active = true">Select second tab</button>
    <button type="button" class="btn btn-primary btn-sm" (click)="tabs[1].active = true">Select third tab</button>
  </p>
  <p>
    <button type="button" class="btn btn-primary btn-sm" (click)="tabs[1].disabled = ! tabs[1].disabled">Enable / Disable third tab</button>
  </p>
  <hr />
  <tabset>
    <tab heading="Static title">Static content</tab>
    <tab *ngFor="#tabz of tabs"
         [heading]="tabz.title"
         [active]="tabz.active"
         (select)="tabz.active = true"
         (deselect)="tabz.active = false"
         [disabled]="tabz.disabled">

    </tab>
    <tab (select)="alertMe()">
      <template tab-heading>
        <i class="glyphicon glyphicon-bell"></i> Alert!
      </template>
      I've got an HTML heading, and a select callback. Pretty cool!
    </tab>
  </tabset>

  <hr />

  <tabset [vertical]="true" type="pills">
    <tab heading="Vertical 1">Vertical content 1</tab>
    <tab heading="Vertical 2">Vertical content 2</tab>
  </tabset>

  <hr />

  <p><i>Bootstrap 4 doesn't have justified classes</i></p>
  <tabset [justified]="true">
    <tab heading="Justified">Justified content</tab>
    <tab heading="SJ">Short Labeled Justified content</tab>
    <tab heading="Long Justified">Long Labeled Justified content</tab>
  </tabset>
</div>

但是当 gulp 编译它时它会给出错误

请纠正我以正确运行它。

【问题讨论】:

    标签: twitter-bootstrap angular-ui-bootstrap angular angular2-directives


    【解决方案1】:

    TAB_DIRECTIVES 好像改名为TAB_COMPONENTS。我尝试了 0.53 版的 ng2-bootstrap。

    这是我在index.html 文件中使用的关于 SystemJS 的配置:

    <script>
      System.config({
        packages: {        
          app: {
            format: 'register',
            defaultExtension: 'js'
          },
          'ng2-bootstrap': {
            format: 'register',
            defaultExtension: 'js'
          }
        },
        map: {
          'ng2-bootstrap': 'node_modules/ng2-bootstrap'
        }
      });
      System.import('app/boot')
            .then(null, console.error.bind(console));
    </script>
    

    希望对你有帮助, 蒂埃里

    【讨论】:

    • 我仍然收到错误找不到输入文件 F:\DemoProjects\TrackMe\client\client\components\home\home.ts。这可能是 gulp-typescript 的问题。请在github.com/ivogabe/gulp-typescript/issues 举报
    • 我正在使用 "ng2-bootstrap": "^0.53.0",
    • 是的,这似乎不是与ng2-bootstrap相关的错误......好吧和我一样的版本!
    猜你喜欢
    • 2021-12-19
    • 2016-10-06
    • 2018-10-19
    • 2017-01-29
    • 2018-12-22
    • 2017-07-07
    • 1970-01-01
    • 1970-01-01
    • 2018-09-25
    相关资源
    最近更新 更多