NullInjectorError occurs when using p-radioButton

UI Components for Angular
Post Reply
aritomo
Posts: 2
Joined: 15 Jun 2021, 06:52

15 Jun 2021, 11:03

Hi team.

When I define a p-radioButton in html, I get an error.
Please tell me the setting error.

My specs.
Windows10
Microsoft Edge 91.0.864.48

error message on browser's console.
core.js:6456 ERROR NullInjectorError: R3InjectorError(AppModule)[NgControl -> NgControl -> NgControl]:
NullInjectorError: No provider for NgControl!
at NullInjector.get (core.js:11081)
at R3Injector.get (core.js:11247)
at R3Injector.get (core.js:11247)
at R3Injector.get (core.js:11247)
at NgModuleRef$1.get (core.js:25341)
at Object.get (core.js:25055)
at lookupTokenUsingModuleInjector (core.js:3342)
at getOrCreateInjectable (core.js:3454)
at NodeInjector.get (core.js:3629)
at RadioButton.ngOnInit (primeng-radiobutton.js:58)
app.component.html

Code: Select all

<p-radioButton></p-radioButton>
app.module.ts

Code: Select all

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

import { RadioButtonModule } from 'primeng/radiobutton';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    RadioButtonModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
package.json

Code: Select all

  "dependencies": {
    "@angular/animations": "^12.0.4",
    "@angular/common": "~12.0.3",
    "@angular/compiler": "~12.0.3",
    "@angular/core": "~12.0.3",
    "@angular/forms": "~12.0.3",
    "@angular/platform-browser": "~12.0.3",
    "@angular/platform-browser-dynamic": "~12.0.3",
    "@angular/router": "~12.0.3",
    "ajv-keywords": "^5.0.0",
    "primeicons": "^4.1.0",
    "primeng": "^12.0.0-rc.1",
    "rxjs": "~6.6.0",
    "tslib": "^2.1.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~12.0.3",
    "@angular/cli": "~12.0.3",
    "@angular/compiler-cli": "~12.0.3",
    "@types/jasmine": "~3.6.0",
    "@types/node": "^12.11.1",
    "jasmine-core": "~3.7.0",
    "karma": "~6.3.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "typescript": "~4.2.3"
  }

aritomo
Posts: 2
Joined: 15 Jun 2021, 06:52

30 Jun 2021, 10:25

This problem has been self-solved.
By specifying [(ngModel)] = "param", Exception no longer occurs.

robertmayy
Posts: 4
Joined: 19 May 2022, 11:12

05 Sep 2022, 10:48

I've had this problem before,pacman 30th anniversary the fix is pretty simple.

thomasfrank
Posts: 2
Joined: 21 Oct 2022, 11:07

21 Oct 2022, 11:11

I also got the same error as you when defining the p-radio Button in HTML.
quordle

trademanager
Posts: 5
Joined: 16 Mar 2023, 05:46

27 Mar 2023, 16:53

As someone else who is experiencing this issue, I would appreciateredactle it if you could help me.

wuckertrhea
Posts: 8
Joined: 23 May 2023, 04:01

24 Aug 2023, 11:20

The same thing happened to me when I tried to define the p-radio Button in HTML. basketball stars

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests