angular: VALID Not Found From Import After Updating to Angular 4

I’m submitting a … (check one with “x”)

[ X ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

After updating to Angular 4 when importing VALID from import from "@angular/form/src/model I get

ERROR in ./src/app/contract/contract.component.ts Module not found: Error: Can’t resolve ‘@angular/forms/src/model’ in

I tracked the file and the imports seem to exist the same way they did in prior versioning

@angular/forms”: “^2.3.1”,

Expected behavior

This feature allows checking validity when using form builder.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

I use it to check if the form is VALID Please tell us about your environment:

OSX MacOS Sierra version 10.12.3

  • Angular version: 2.0.X

Angular 4.0.0

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

This never runs in the browser because the application does not compile without errors.

  • Language: [all | TypeScript X.X | ES6/7 | ES5] ES5

  • Node (for AoT issues): node --version =
    v7.2.1

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (4 by maintainers)

Most upvoted comments

If anything I personally think that INVALID and other status constants should be removed and the types should be inline eg: status: 'VALID'|'INVALID'|'PENDING'|'DISABLED' which will help with IDE support and enforce the decision made in this issue

Yep, VALID is not currently exported (private API). You should be able to use control.valid or control.status === 'VALID' for the same purpose.

@kara why closing this issue? I think it would be very beneficial to make these constant public again.

Hmm…

import {INVALID} from "@angular/forms/src/model";

Results in:

Module not found: Error: Can't resolve '@angular/forms/src/model' in '...'

I’m using angular-cli but according to @filipesilva the problem belongs to angular itself. That’s how I came here. https://github.com/angular/angular-cli/issues/5735

model.d.ts states:

/**
 * Indicates that a FormControl is invalid, i.e. that an error exists in the input value.
 */
export declare const INVALID = "INVALID";

Well, does this mean that I have to use “INVALID” as a string in my code several times? Or to re-implement the interface by myself – risking an application-wide regression on version upgrade?

I consider both a bad practice and would like to use the constants instead.

For my understanding, this is not a resolved issue. I guess @sittingbool and @Toxicable, @rokerkony and @amostech would also agree on that…?

@kara @DzmitryShylovich Those are probably new arguments in the debate. Would you mind, taking them into consideration?

I would also like to report here that the method isPropertyUpdated from @angular/forms is also not reachable anymore. This created a bug while trying to create a solution for binding contenteditable two-way binding.

Any chance we can export the methods from @angular/forms? If not, I will use a workaround that doesn’t support two-way binding.

Obviously this one ended up being an easy fix but if something a little more complicated comes up?

If you need something that is not exported open a new issue and we will consider to export it.

Why did you need to import from @angular/forms/src/model? Try to import { something } from @angular/forms