简体   繁体   English

单击文本文件中的按钮后,在框中填写值

[英]Fill value in box on click of a button from a text file

I have the below box to fill up the information : 我在下面的框中填写信息:

在此处输入图片说明

I have the below code to create the above box : 我有以下代码来创建上述框:

 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <!-- server Location Field --> <div class="form-group" style="width: 80%; margin-left:10%;" > <span style="position: relative;color:red; left: -10px"><font>*</font> </span> <input maxlength="20" type="text" class="form-control filled" ng-model="ctrl.form1.serverLocation" placeholder="serverLocation" name="serverLocation" ng-required="ctrl.form1.date=='Enable'"></input> <span ng-show="f2.serverLocation.$dirty && f2.serverLocation.$error.required" style="color: red"> server Location is required</span> </div> 

I am trying to create a button , clicking on which the value to be filled inside the box is fetched from a .text file.For instance , for the above box the value to be picked from the text file is "server_location" . 我正在尝试创建一个按钮,单击该按钮后,将从.text文件中提取要填充到框内的值。例如,对于上述框,要从文本文件中选取的值是“ server_location”。 The text file includes many fields such as : 文本文件包含许多字段,例如:

 image_location=pqc_11 db_location=xyz_2233 server_location=abc-1122 

Kindly help on how to fill up the box on click of a button .I am using angular JS to create the fill up box .Thanks in advance. 请在单击按钮时填充框。请使用角度JS创建填充框。谢谢。

I think you should work on angular 2 as your life will be easier. 我认为您应该研究角度2,因为您的生活会更轻松。 On AngularJS simply use ngClick https://docs.angularjs.org/api/ng/directive/ngClick 在AngularJS上,只需使用ngClick https://docs.angularjs.org/api/ng/directive/ngClick

Add it on your input, then fill the value field 将其添加到您的输入中,然后填写值字段

Where fillInput() can both use : 其中fillInput()都可以使用:

1 - ElementRef to access DOM element and change it. 1-ElementRef访问并更改DOM元素。

2 - ViewChild <input #viewInput type="text" value="{{serverLocation}}"/> 2-ViewChild <input #viewInput type="text" value="{{serverLocation}}"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM