1
votes

I have a Angular 2 Inline Editing component in plunker. But suddenly i'm getting the above error. What happened to it?

Plunker code: http://plnkr.co/edit/3AODo6YGEhvPOKzloofz?p=preview

Parent component:

<inline-edit [editEnable]="edit" [(ngModel)]="editableText" (onSave)="saveEditable($event)"></inline-edit>

Child component:

<div id="inlineEditWrapper" (click)="edit(value)" class="iedit">
    <!-- Editable value -->
    <a  [hidden]="editing">{{ value }}&nbsp;<i class="glyphicon glyphicon-pencil" data-hidden="editing"></i></a>

    <!--<span class="glyphicon glyphicon-pencil" [hidden]="editing"></span>-->

    <!-- inline edit form -->
    <form  #inlineEditForm="ngForm" class="inlineEditForm form-inline" (ngSubmit)="onSubmit(value)" [hidden]="!editing">
        <div class="form-group">

            <!-- inline edit control  -->
           <input style="margin-bottom:10px;" #inlineEditControl class="form-control" [(ngModel)]="value"/>

            <!-- inline edit save and cancel buttons -->
            <br/>
           <span >
                <button type="submit" class="btn btn-primary">Change</button>
                <button class="btn btn-default" (click)="cancel(value)">Cancel</button>
           </span>

        </div>
    </form>
</div>
1
What angular2 version did you use?jmvtrinidad
Angular 2 RC4 version.Varun

1 Answers

3
votes

You can follow some steps:

Step 1: Load package for angular forms

'@angular/forms': {
      main: 'bundles/forms.umd.js',
      defaultExtension: 'js'
}

Step 2: Import disableDeprecatedForms, provideForms

import {disableDeprecatedForms, provideForms} from '@angular/forms';

bootstrap(App, [
   disableDeprecatedForms()
   provideForms()
]).catch(err => console.error(err));

Step 3: Import ControlValueAccessor, NG_VALUE_ACCESSOR from "@angular/forms" in inline-edit.component.ts

Step 4: Adjust your input element in the form as:

<input style="margin-bottom:10px;" #inlineEditControl class="form-control" name="first_name" #first_name="ngModel" [(ngModel)]="value"/>

That work for me at here