我有一个应该这样显示的 div,但是当您单击该 div 时,我需要它转换为输入字段。
这是我在单击 div 之前所得到的:
<div>This is the content.</div>
Run Code Online (Sandbox Code Playgroud)
我希望点击后变成以下内容:
<input>This is the content.</input>
Run Code Online (Sandbox Code Playgroud)
并在用户单击其他地方时更改回来。
Angular 可以实现这样的事情吗?我研究过使用 ng-change 作为 HTML 标签,但我似乎无法让它继续下去。
任何帮助表示赞赏。
尝试这个
<div ng-click='toggleShowInput()' ng-hide='showInput' >This is the content.</div>
<input ng-show='showInput'>This is the content.</input>
Run Code Online (Sandbox Code Playgroud)
控制器的功能如下
function cntrl($scope){
$scope.showInput = false;
$scope.toggleShowInput = function()
{
$scope.showInput = !$scope.showInput;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5206 次 |
| 最近记录: |