<commit_before>import { Component, ElementRef, EventEmitter } from '@angular/core';
import { COMMON_DIRECTIVES, Control, Validators } from '@angular/common';
import moment from 'moment/moment';

import { NOVO_DATE_PICKER_ELEMENTS } from './../../../datepicker';
import { OutsideClick } from './../../../../utils/outside-click/OutsideClick';
import { NovoLabelService } from './../../../../novo-elements';

@Component({
    selector: 'date-input',
    inputs: ['name', 'placeholder', 'inline', 'required'],
    outputs: ['inputState'],
    properties: ['placeholder', 'inline'],
    directives: [NOVO_DATE_PICKER_ELEMENTS, COMMON_DIRECTIVES],
    template: `
        <i *ngIf="required" class="required-indicator" [ngClass]="{'bhi-circle': !control.valid, 'bhi-check': control.valid}"></i>
        <input [name]="name" type="text" [attr.id]="name" [placeholder]="placeholder" (focus)="toggleInactive($event)" (blur)="toggleInactive($event)" (click)="toggleActive($event)" [ngModel]="value" [ngFormControl]="control" readonly/>
        <i (click)="toggleActive($event)" class="bhi-calendar"></i>
        <novo-date-picker [inline]="inline" [hidden]="!active" (onSelect)="onSelect($event); toggleInactive($event)"></novo-date-picker>
        <span class="error-message" *ngIf="required && control.touched && control?.errors?.required">{{labels.required}}</span>
    `
})
export class DateInput extends OutsideClick {
    inactive:Boolean = false;
    validators:Array = [];
    inputState:EventEmitter = new EventEmitter();

    constructor(element:ElementRef, labels:NovoLabelService) {
        super(element);
        this.labels = labels;
    }

    ngOnInit() {
        if (this.value) {
            this.value = moment(this.value).format('MMMM DD, YYYY');
        }
        if (this.required) {
            this.validators.push(Validators.required);
        }
        this.control = new Control('', Validators.compose(this.validators));
<commit_msg>bug(Form): DateInput value does not bind to ngModel (#139)<commit_after>import { Component, ElementRef, EventEmitter } from '@angular/core';
import { COMMON_DIRECTIVES, Control, Validators } from '@angular/common';
import moment from 'moment/moment';

import { NOVO_DATE_PICKER_ELEMENTS } from './../../../datepicker';
import { OutsideClick } from './../../../../utils/outside-click/OutsideClick';
import { NovoLabelService } from './../../../../novo-elements';

@Component({
    selector: 'date-input',
    inputs: ['name', 'placeholder', 'inline', 'required'],
    outputs: ['inputState'],
    properties: ['placeholder', 'inline'],
    directives: [NOVO_DATE_PICKER_ELEMENTS, COMMON_DIRECTIVES],
    template: `
        <i *ngIf="required" class="required-indicator" [ngClass]="{'bhi-circle': !control.valid, 'bhi-check': control.valid}"></i>
        <input [name]="name" type="text" [attr.id]="name" [placeholder]="placeholder" (focus)="toggleInactive($event)" (blur)="toggleInactive($event)" (click)="toggleActive($event)" [ngModel]="value" [ngFormControl]="control" readonly/>
        <i (click)="toggleActive($event)" class="bhi-calendar"></i>
        <novo-date-picker [inline]="inline" [hidden]="!active" (onSelect)="onSelect($event); toggleInactive($event)" [ngModel]="value"></novo-date-picker>
        <span class="error-message" *ngIf="required && control.touched && control?.errors?.required">{{labels.required}}</span>
    `
})
export class DateInput extends OutsideClick {
    inactive:Boolean = false;
    validators:Array = [];
    inputState:EventEmitter = new EventEmitter();

    constructor(element:ElementRef, labels:NovoLabelService) {
        super(element);
        this.labels = labels;
    }

    ngOnInit() {
        if (this.value) {
            this.value = moment(this.value).format('MMMM DD, YYYY');
        }
        if (this.required) {
            this.validators.push(Validators.required);
        }
        this.control = new Control('', Validators.compose(this.validators));

{'fraction_non_alphanumeric': 0.18688524590163935, 'fraction_numerical': 0.0007566204287515763, 'mean_word_length': 3.994962216624685, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6979971', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1184, 'n_words': 221}