2017-10-11 86 views

回答

-1

問題你給ngModel變量賦予了什麼價值?那就是問題

更新是這樣的。

value:string = 'hello' 
     to 
value:string = ''; or value:string; 

聲明空變量。

使用佔位--->floatingLabel="First name"這樣

其解決您的問題!

Iam更新了你的plunker代碼iam檢查了它的工作。檢查此代碼並運行。

import { Component } from '@angular/core'; 

@Component({ 
    selector: 'my-app', 
    template: ` 
    <kendo-textbox-container floatingLabel="First name"> 
     <input kendoTextBox [(ngModel)]="value"/> 
     </kendo-textbox-container> 
    ` 
    }) 
export export class AppComponent { 
    value:string = ''; 
} 
+0

我不明白「使用佔位符---> floatingLabel =」這樣的名字「。我不想用佔位符 –

+0

標籤重疊內容>>>>>你的問題這個。 因此,這就是爲什麼iam告訴不使用兩種類型的分配值。 使用 floatingLabel =「名字」(或)值:字符串='你好' –

+0

我需要指定值並看到floatingLabel作爲屏幕截圖中的第二個圖像。問題是,當「模糊」時,浮動標籤返回的內容而不是塊的輸入 –

0

這裏是一個合適的解決方法。它手動設置容器的focused標誌,以便標籤轉到其他位置。

import { AfterViewInit, Component } from '@angular/core'; 

@Component({ 
    selector: 'my-app', 
    template: ` 
    <kendo-textbox-container floatingLabel="First name"> 
     <input kendoTextBox [(ngModel)]="value"/> 
     </kendo-textbox-container> 
    ` 
    }) 
export export class AppComponent implements AfterViewInit { 
    value:string = 'hello' 

    @ViewChild(TextBoxContainerComponent) container; 

    // workaround for floatingLabel overlapping 
    ngAfterViewInit() { 
     window.setTimeout(() => this.container.focused = true, 0); 
    } 
} 

乾杯!