【发布时间】:2018-07-08 22:07:54
【问题描述】:
收到消息
如果 'ngb-xx' 是 Angular 组件,则验证它是 这个模块
对于我尝试的每个角度引导组件
设置过程
npm install angular-cli
ng new project
npm install
npm install --save bootstrap
npm install --save @ng-bootstrap/ng-bootstrap
在 app.module.ts 中
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http' ;
import { NgbModule } from '@ng-bootstrap/ng-bootstrap' ;
import { AppComponent } from './app.component';
import { NgForm } from '@angular/forms/src/directives/ng_form';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
NgbModule.forRoot()
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
在 .angular-cli.json 中
"styles": [
"styles.css",
"../node_modules/bootstrap/dist/css/bootstrap.min.css"
],
甚至尝试添加 npm install --save jquery 并在 .angular-cli.json 中
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
],
在app.component.html中添加
<ngb-tabset>
<ngb-tab title="test">
<template ngbTabContent>
xxx ss
</template>
</ngb-tab>
<ngb-tab title="test">
<template ngbTabContent>
xxxs ss
</template>
</ngb-tab>
</ngb-tabset>
<p>
<ngb-alert [dismissible]="false">
<strong>Warning!</strong> Better check yourself, you're not looking too good.
</ngb-alert>
</p>
css 似乎可以工作,但业力错误且没有 js
失败:模板解析错误:“ngb-tab”不是已知元素:
如果 'ngb-tab' 是 Angular 组件,则验证它是该模块的一部分。
如果“ngb-tab”是 Web 组件,则将“CUSTOM_ELEMENTS_SCHEMA”添加到该组件的“@NgModule.schemas”以禁止显示此消息。
("
只限警告
失败:模板解析错误:无法绑定到“dismissible”,因为它 不是“ngb-alert”的已知属性。
如果 'ngb-alert' 是一个 Angular 组件并且它具有 'dismissible' 输入,则验证它是该模块的一部分。
如果“ngb-alert”是一个 Web 组件,则将“CUSTOM_ELEMENTS_SCHEMA”添加到该组件的“@NgModule.schemas”以禁止显示此消息。
要允许任何属性将“NO_ERRORS_SCHEMA”添加到此组件的“@NgModule.schemas”。
请帮忙谢谢
看起来问题似乎来自业力/茉莉花设置
这是我的 karma.conf.js
// Karma 配置文件,更多信息见链接 //https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
【问题讨论】:
-
您的代码绝对没问题,请分享您使用的代码
ngb-tab。 -
嗨 @VivekDoshi 感谢刚刚添加到内容中
-
嗨@VivekDoshi 谢谢你的回答演示让我走上了正确的轨道看起来这里真正的问题似乎是业力/茉莉花设置,因为应用程序正在自行运行,但业力/茉莉花正在抛出错误
标签: angular twitter-bootstrap angular-cli ng-bootstrap