0

I have a project which I have recently migrated to Angular 9 from Angular 8 . The project uses primeng version : 4.3.0 . Now the p-radiobutton tag is widely used through out the project to display radio buttons and it is not working properly . The p-radiobutton tag gives the runtime error : Unable to get property 'nativeElement' of undefined or null reference due to which , the UI gets distorted . The entire error stack trace is depicted down below :

TypeError: Unable to get property 'nativeElement' of undefined or null reference
   at RadioButton.prototype.writeValue (http://localhost:4200/vendor.js:115296:9)
   at setUpControl (http://localhost:4200/vendor.js:79928:5)
   at NgModel.prototype._setUpStandalone (http://localhost:4200/vendor.js:82718:9)
   at NgModel.prototype._setUpControl (http://localhost:4200/vendor.js:82706:32)
   at NgModel.prototype.ngOnChanges (http://localhost:4200/vendor.js:82630:13)
   at checkAndUpdateDirectiveInline (http://localhost:4200/vendor.js:67503:9)
   at checkAndUpdateNodeInline (http://localhost:4200/vendor.js:76327:13)
   at checkAndUpdateNode (http://localhost:4200/vendor.js:76289:9)
   at prodCheckAndUpdateNode (http://localhost:4200/vendor.js:76833:5)
   at Anonymous function (Function code:194:5)

The line of code in the html due to which the error is being thrown is this :

<td class="alignHere">
    <p-radioButton name="myStuff" value="CAT" [(ngModel)]="StuffChosen"></p-radioButton>
</td> 

When I comment out the above piece of code, the error does no come up anymore , but I need to use the radio button functionality .

Does anybody have any idea about what this error is and what can be a potential solution to this problem ? Any help is deeply appreciated .

The Dark Knight
  • 5,455
  • 11
  • 54
  • 95

1 Answers1

0

primeng line the versions with angular version , this mean primeng 10 is used for angular 10 , primeng 11 for angular 11 and this apply to old version.

you get an error because in primeng 4 some angular api has changed or removed.

to solve your problem just chose the primeng version base of your angular app version

Muhammed Albarmavi
  • 23,240
  • 8
  • 66
  • 91
  • I solved my problem by patching the primeng 4 radiobutton.js using the patch-package library . It was a life saver for me as I did not have the bandwidth to upgrade prime-ng. – The Dark Knight Dec 09 '20 at 14:48