angularjs text area character counter

后端 未结 4 1994
无人及你
无人及你 2020-12-03 00:51

Hi I have a characeter counter for a text area. My problem is that it doesn\'t count spaces or linebreaks. How do I make it so that it does so?

   
4条回答
  •  囚心锁ツ
    2020-12-03 01:18

    With Angular, textarea has an optional argument called ngTrim. According to the Angular textarea page:

    If set to false Angular will not automatically trim the input. (default: true)

    Usage:

    
    

    The following code shows how to use ngTrim in order to prevent Angular to trim the input:

    
    
    
    
        
        Character count
        
    
    
    
        
        

    {{15 - countmodel.length}} left


    Note that input[text] has the same optional ngTrim argument (Angular input page).

提交回复
热议问题