在输入标签内格式化ng-init文本-AngularJS

时间:2018-12-06 10:59:12

标签: angularjs

我在ng-init标记中定义了input。我希望此输入采用指定的格式并带有换行符。

我也尝试使用<pre>标签和white-space:pre-line属性。但这似乎没有得到解决。

<div style="font-family: Poppins !important;-webkit-font-smoothing: antialiased;top:35%; position:absolute; width: 100%; background:transparent !important; margin-bottom:0rem !important">
   <input class="form-control"
      id="volunteerCallTextId" type="text" placeholder="Volunteer Call Text"
      ng-model="volunteerCallText"
      ng-init="volunteerCallText ='Hello, may I speak to (Insured).  Hi (Mr., Mrs. Etc), my name is _________.  
      I am with xxx Insurance and am calling you about the recent fire/flood/weather event in_____.  
      We are calling to check and see if your family is safe and let you know that xxx is here for you.   
      I want to let you know that we have emergency claims locations set up at: (use locations below).  
      Or you can call our Claims center at 888....Please be aware that.....'" 
      style="width: 75em; height:25em; white-space:pre-line" />
</div>

期望的格式:

  

您好,我可以和(被保险人)通话吗?嗨(先生,太太),我叫   _________。
  我加入xxx Insurance,并就in_____最近发生的火灾/洪水/天气事件致电给您。我们正在呼吁检查和   看看您的家人是否安全,并告诉您xxx在这里。
  我想告诉您,我们已经设置了紧急索赔地点   位于:(使用下面的位置)。或者您可以致电我们的理赔中心   888 ....请注意.....

有人可以建议可以做什么吗?

1 个答案:

答案 0 :(得分:1)

我不确定是否可以在输入框中完成此操作,但它在textarea中的工作原理如下,请尝试让我知道是否对您有所帮助

<!DOCTYPE html>
    
    <html>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
    <body>
    
    <div ng-app="" >
    
    <div style="font-family: Poppins !important;-webkit-font-smoothing: antialiased;top:35%; position:absolute; width: 100%; background:transparent !important; margin-bottom:0rem !important">
       <textarea class="form-control"
          id="volunteerCallTextId" style="width:75em; height:25em; white-space: pre-wrap;" type="text" placeholder="Volunteer Call Text"
          ng-model="volunteerCallText"
          ng-init="volunteerCallText ='Hello, may I speak to (Insured).  Hi (Mr., Mrs. Etc), my name is _________ \n\
I am with xxx Insurance and am calling you about the recent fire/flood/weather event in_____.\n\
We are calling to check and see if your family is safe and let you know that xxx is here for you.I want to let you know that we have emergency claims locations set up at: (use locations below).Or you can call our Claims center at 888....Please be aware that.....'"
           ></textarea>
    </div>
    </div>
    </body>
    </html>