Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 单击即可将字段类型从div转换为输入_Html_Angularjs - Fatal编程技术网

Html 单击即可将字段类型从div转换为输入

Html 单击即可将字段类型从div转换为输入,html,angularjs,Html,Angularjs,我有一个div,应该显示为这样,但是当你点击这个div时,我需要它转换成一个输入字段 这是我在单击该div之前看到的: <div>This is the content.</div> <input>This is the content.</input> 这是内容。 单击后,我希望它成为以下内容: <div>This is the content.</div> <input>This is the con

我有一个div,应该显示为这样,但是当你点击这个div时,我需要它转换成一个输入字段

这是我在单击该div之前看到的:

<div>This is the content.</div>
<input>This is the content.</input>
这是内容。
单击后,我希望它成为以下内容:

<div>This is the content.</div>
<input>This is the content.</input>
这是内容。
并在用户单击其他位置时返回

这样的事情有可能发生吗?我考虑过使用ng change作为HTML标记,但我似乎无法让它运行起来


非常感谢您的帮助。

如果您使用Angular,您应该编写两个元素,并在用户单击时切换其中一个:


点击这里
试试这个

<div ng-click='toggleShowInput()' ng-hide='showInput' >This is the content.</div>
<input ng-show='showInput'>This is the content.</input>

不,但好消息是你不需要这样做

在控制器中:

$scope.showInput = false;
$scope.myContent = "This is the content";
返回HTML文件:

{{myContent}

您可以查看链接,这是一个非常有用的答案,因为它还可以教您如何更好地完成反向作业。我过去常做if(true){var=false;}else{var=true;},你的方法读起来非常好。非常感谢:)