Reputation: 2405
Getting the message
If 'ngb-xx' is an Angular component, then verify that it is part of this module
for every angular bootstrap components that i try
Setup process
npm install angular-cli
ng new project
npm install
npm install --save bootstrap
npm install --save @ng-bootstrap/ng-bootstrap
In 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 { }
In .angular-cli.json
"styles": [
"styles.css",
"../node_modules/bootstrap/dist/css/bootstrap.min.css"
],
Even try add npm install --save jquery and in .angular-cli.json
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
],
in app.component.html add
<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>
the css seems to work but karma errors and no js
Failed: Template parse errors: 'ngb-tab' is not a known element:
If 'ngb-tab' is an Angular component, then verify that it is part of this module.
If 'ngb-tab' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
("
ngalert only
Failed: Template parse errors: Can't bind to 'dismissible' since it isn't a known property of 'ngb-alert'.
If 'ngb-alert' is an Angular component and it has 'dismissible' input, then verify that it is part of this module.
If 'ngb-alert' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
Please help thanks
Looks like the problem seems to be comming from karma/jasmine setup
here is my karma.conf.js
// Karma configuration file, see link for more information // 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
});
};
Upvotes: 4
Views: 23232
Reputation: 2405
Finally find the problem
when installing and configuring modules dont forget to inset into test.spec.ts
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap' ;
import { BrowserModule } from '@angular/platform-browser';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
NgbModule.forRoot()
],
}).compileComponents();
}));
Upvotes: 2
Reputation: 58593
Issue is here :
npm install angular-cli
ng new project
npm install
npm install --save bootstrap
npm install --save @ng-bootstrap/ng-bootstrap
You Forgot to go in to the directory after project creation
npm install angular-cli
ng new project
cd 'project' // <-------------- Here , you missed this
npm install
npm install --save bootstrap
npm install --save @ng-bootstrap/ng-bootstrap
Another issue I can find here is <template ngbTabContent>
Change <template ngbTabContent>
to <ng-template ngbTabContent>
and also
</template>
to </ng-template>
.
Upvotes: 4