Tuesday, February 19, 2019

ERROR Error: Uncaught (in promise): ReferenceError: Validators is not defined

Hi Guys ,

Today I have faced this error :

ERROR Error: Uncaught (in promise): ReferenceError: Validators is not defined

When I check the command prompt the error is like this :
-----ng serve--------------------------------------------------------------------------------------------------------------

ERROR in src/app/sign-up/sign-up.component.ts(17,27): error TS2304: Cannot find name 'Validators'.
src/app/sign-up/sign-up.component.ts(17,48): error TS2304: Cannot find name 'Validators'.
src/app/sign-up/sign-up.component.ts(17,73): error TS2304: Cannot find name 'Validators'.
-----------------------------------------------------------------------------------------------------------------------

The solution is to add the following line in your component.ts file, highlighted in Yellow.

import { Validators } from '@angular/forms';


The complete console log is as below:


ERROR Error: Uncaught (in promise): ReferenceError: Validators is not defined
ReferenceError: Validators is not defined
    at new SignUpComponent (sign-up.component.ts:17)
    at createClass (core.js:9292)
    at createDirectiveInstance (core.js:9179)
    at createViewNodes (core.js:10399)
    at createRootView (core.js:10313)
    at callWithDebugContext (core.js:11344)
    at Object.debugCreateRootView [as createRootView] (core.js:10831)
    at ComponentFactory_.push../node_modules/@angular/core/fesm5/core.js.ComponentFactory_.create (core.js:8659)
    at ComponentFactoryBoundToModule.push../node_modules/@angular/core/fesm5/core.js.ComponentFactoryBoundToModule.create (core.js:3311)
    at ViewContainerRef_.push../node_modules/@angular/core/fesm5/core.js.ViewContainerRef_.createComponent (core.js:8769)
    at resolvePromise (zone.js:831)
    at resolvePromise (zone.js:788)
    at zone.js:892
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Object.onInvokeTask (core.js:3811)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
    at drainMicroTaskQueue (zone.js:601)
defaultErrorLogger @ core.js:1673
localhost/:1 Unchecked runtime.lastError: The message port closed before a response was received.
core.js:1673 ERROR Error: Uncaught (in promise): ReferenceError: Validators is not defined
ReferenceError: Validators is not defined
    at new SignUpComponent (sign-up.component.ts:17)
    at createClass (core.js:9292)
    at createDirectiveInstance (core.js:9179)
    at createViewNodes (core.js:10399)
    at createRootView (core.js:10313)
    at callWithDebugContext (core.js:11344)
    at Object.debugCreateRootView [as createRootView] (core.js:10831)
    at ComponentFactory_.push../node_modules/@angular/core/fesm5/core.js.ComponentFactory_.create (core.js:8659)
    at ComponentFactoryBoundToModule.push../node_modules/@angular/core/fesm5/core.js.ComponentFactoryBoundToModule.create (core.js:3311)
    at ViewContainerRef_.push../node_modules/@angular/core/fesm5/core.js.ViewContainerRef_.createComponent (core.js:8769)
    at resolvePromise (zone.js:831)
    at resolvePromise (zone.js:788)
    at zone.js:892
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Object.onInvokeTask (core.js:3811)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
    at drainMicroTaskQueue (zone.js:601)
    at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:502)
    at invokeTask (zone.js:1744)
defaultErrorLogger @ core.js:1673

No comments:

Post a Comment

ec2-user@ec2 Permission denied