Angular 2, Typescript The module does not have exported constants 'FORM_DIRECTIVES'

I am trying to include one existing component in my application and from the sample code, I have these dependencies:

import {CORE_DIRECTIVES, FORM_DIRECTIVES, NgClass} from 'angular2/common';

Now I use '@angular'instead 'angular2', which I think would be something like this:

import { Component, OnInit, CORE_DIRECTIVES } from '@angular/core';
import { FORM_DIRECTIVES } from '@angular/forms';

However i get this error

mypath/node_modules/@angular/forms/index"' has no exported member 'FORM_DIRECTIVES'.
mypath/node_modules/@angular/core/index"' has no exported member 'CORE_DIRECTIVES'.

How can I include FORM_DIRECTIVES, and if they are no longer part angular2, what is a replacement or a new way to resolve dependencies?

I checked angular changelog but found nothing

+4
source share
2 answers

FORM_DIRECTIVES FormsModule, FormsModule .

CORE_DIRECTIVES CommonModule, BrowserModule. BrowserModule AppModule, CORE_DIRECTIVES. FormsModule:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppComponent }  from './app.component';

@NgModule({
    imports: [
        BrowserModule,
        FormsModule
    ],
    declarations: [
        AppComponent
    ],
    bootstrap: [AppComponent]
})

export class AppModule { }
+8

:

npm install --save angular2

:

 "dependencies": {
    "@ngrx/store": "^1.2.1",
    "angular2": "^2.0.0-beta.7",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.2",
    "zone.js": "0.5.15"
  }

:

import {ControlGroup, Control, FORM_DIRECTIVES} from "angular2/common";

@Component({
    selector: 'person-form',
    directives: [FORM_DIRECTIVES],
    template: require('./person_form.html')
})

export class PersonForm { ... } 
This fails with FORM_DIRECTIVES as undefined:

import {ControlGroup, Control} from "angular2/common";

@Component({
    selector: 'person-form',
    directives: [FORM_DIRECTIVES],
    template: require('./person_form.html')
})

export class PersonForm { ... } 
+2

Source: https://habr.com/ru/post/1656075/


All Articles