uppercase directive not update input angular

Discussão em 'Angular' iniciado por Davi Resio, Outubro 23, 2024.

  1. Davi Resio

    Davi Resio Guest

    this uppercase directive not work on angular.... if i print a console.log() to see value on format method i can see the value of i input, but the text not update to uppercase on inputText;

    my declaration on html


    <input type="text" uppercase >
    ​

    import {Directive, Input, Output, EventEmitter, OnInit} from 'angular2/core';

    @Directive({
    selector: '[uppercase]',
    host: {
    '[value]': 'uppercase',
    '(input)': 'format($event.target.value)'
    }
    })
    export class Uppercase implements OnInit {

    @Input() uppercase: string;
    @Output() uppercaseChange: EventEmitter<string> = new EventEmitter<string>();

    constructor() {
    }

    ngOnInit() {
    this.uppercase = this.uppercase || '';
    this.format(this.uppercase);
    }

    format(value) {
    value = value.toUpperCase();
    this.uppercaseChange.next(value);
    }
    }


    how i can do to text uppercase?

    Continue reading...

Compartilhe esta Página