How to deal with loss of deep imports in Angular 4

I just updated to Angular 4

and found out that it no longer supports deep imports

.

So I used VALID to help validate forms. But now that I cannot import it withdeep import

import { VALID } from '@angular/forms/src/model 

      

And since it doesn't work,

import { VALID } from '@angular/forms/'

      

What should we do to get access to it? Or anything for that matter that has previously been addressed with help deep import

?

+3


source to share


2 answers


Angular 4

no longer supports deep imports. In Angular 2

you can do this,

import { VALID } from '@angular/forms/src/model'  

      

but now in Angular 4

you can only go to the first level,

import { VALID } from '@angular/forms' 

      

So basically anything you get by deep importing can no longer be used unless it is exported, which will make it available so you can access it from that first level.

So in my case VALID

it failed. So to test, I just tested it with line response from checking input field for blur instead of bool.



formInputValidate(inputField: string, ErrorTitle: string, ErrorMessage: string) {
  if (this.profileForm.get(inputField).status === 'VALID') {
    this.toastSuccess(inputField, ' entered correctly');
  } else {
    this.toastWarning(ErrorTitle, ErrorMessage);
  }
}

      

Which brings up a new question,

In my case, this was easy to fix. But if the situation is more complex and the deep import helper was critical, how do we get around it?

I asked the Angular contributors on git here and they said,

enter image description here

So, it looks like if we need someone, we can request them and they will consider it!

0


source


for ppl has the same issue, can link to: https://github.com/angular/angular/issues/15542#issuecomment-289671010



-1


source







All Articles