question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NullInjectorError: No provider for SchemaValidatorFactory

See original GitHub issue

I just recreated the example but I immediately got the following error: Any clue on what could be wrong?

ERROR Error: StaticInjectorError[SchemaValidatorFactory]: 
  StaticInjectorError[SchemaValidatorFactory]: 
    NullInjectorError: No provider for SchemaValidatorFactory!
    at _NullInjector.get (core.js:993)
    at resolveToken (core.js:1281)
    at tryResolveToken (core.js:1223)
    at StaticInjector.get (core.js:1094)
    at resolveToken (core.js:1281)
    at tryResolveToken (core.js:1223)
    at StaticInjector.get (core.js:1094)
    at resolveNgModuleDep (core.js:10878)
    at NgModuleRef_.get (core.js:12110)
    at resolveDep (core.js:12608)

My setup is simple:

app.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  // Bind the 'mySchema' member to the schema input of the Form component.
  template: '<sf-form [schema]="mySchema"></sf-form>'
})

export class AppComponent {
  // The schema that will be used to generate a form
  mySchema = {
    'properties': {
      'email': {
        'type': 'string',
        'description': 'email',
        'format': 'email'
      },
      'password': {
        'type': 'string',
        'description': 'Password'
      },
      'rememberMe': {
        'type': 'boolean',
        'default': false,
        'description': 'Remember me'
      }
    },
    'required': ['email', 'password', 'rememberMe']
  };
}

app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { SchemaFormModule, WidgetRegistry, DefaultWidgetRegistry } from 'angular2-schema-form';
import { AppComponent } from './app.component';

@NgModule({
  imports: [
    SchemaFormModule,
    BrowserModule
  ],
  declarations: [AppComponent],
  providers: [{provide: WidgetRegistry, useClass: DefaultWidgetRegistry}],
  bootstrap: [AppComponent]
})
export class AppModule {}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

6reactions
rajc2018commented, Jan 16, 2018

Awesome, exactly what I was looking for, “SchemaFormModule.forRoot()” worked for me

6reactions
daniele-pecoracommented, Jan 4, 2018

Yep, like told in #173 the import must be now be rewritten this way, to have the default SchemaValidatorFactory working.

imports: [
    ...
    // schema form module
    , SchemaFormModule.forRoot()
   ...
  ],
Read more comments on GitHub >

github_iconTop Results From Across the Web

NullInjectorError: No provider for class - angular - Stack Overflow
I have injected class as dependency injection in component class and get an error. NullInjectorError: No provider for class.
Read more >
nullinjectorerror: no provider for service
You might have faced an error like " StaticInjectorError NullInjectorError: No provider for MyService". This error comes when you try to create a...
Read more >
ng-alain_plia的博客-CSDN博客_ng-alain
... SchemaValidatorFactory]: NullInjectorError: No provider for SchemaValidatorFactory! at _NullInjector.get (core.js:1003) at resolveToken ...
Read more >
Top 5 ngx-schema-form Code Examples - Snyk
To help you get started, we've selected a few ngx-schema-form examples, based on popular ways it is used in public projects. Secure your...
Read more >
No provider for MockClientService - DevAsking
To fix NullInjectorError: No provider for HttpClient! error in Angular follow the ... StaticInjectorError[SchemaValidatorFactory]: NullInjectorError: No ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found