anchy17
anchy17

Reputation: 93

No provider for BsModalService, what I need to change?

usermodule.ts

Imports:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser';
import { UsersRoutingModule } from './users-routing.module';
import { UserListComponent } from './user-list/user-list.component';
import { ModalModule } from 'ngx-bootstrap/modal';


@NgModule({
 declarations: [UserListComponent],

Should I add some in imports?

   imports: [
    CommonModule,
    BrowserModule,
    UsersRoutingModule,
    ModalModule.forRoot()
   ],

Should I add some in providers?

  providers: 
 })
  export class UsersModule { }

Upvotes: 4

Views: 16032

Answers (3)

Mick
Mick

Reputation: 917

You need to add a provider for BsModalService

providers: [BsModalService]

Upvotes: 10

Robert Tab
Robert Tab

Reputation: 174

if there are others with the same problem, here is the solution worked for me: I had to remove the .angular\cache and it worked again as it should.

For me, everything was working as it should, but suddenly I got the error and couldn't start the app until I deleted the cache. I hope this answer will help somebody in the future.

Upvotes: 1

Saahithyan Vigneswaran
Saahithyan Vigneswaran

Reputation: 7143

imports: [ModalModule.forRoot(),...]

In latest version of angular imports is more preferable, for more reference

Upvotes: 10

Related Questions