<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
</script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js">
</script>
<head>
<body>
<div ng-app="">
<label class="control-label"> Name:</label>
<div class="input-group col-lg-4 col-md-4 col-sm-4 col-xs-4">
<input type="text" class="form-control" ng-model="name" ng-disabled="bname" ng-init="bname=true;" value="Default Value">
<span class="input-group-addon">
<a ng-click="bname=!bname" title="Click here to Change your name">
<span class="glyphicon glyphicon-edit"></span></a>
</span>
</div>
</div>
</body>
</html>
&#13;
启用禁用后(使用ng-init禁用并通过按钮单击启用)文本输入框默认输入框值未显示在angularjs中,任何人都可以执行此操作吗?任何形式的帮助表示赞赏,因为我是新手。 w3c示例:w3schools.com tryit editor
答案 0 :(得分:0)
初始化角度属性&#34; name&#34;使用ng-init remove value属性,如下所示:
<input type="text" class="form-control" ng-model="name"
ng-disabled="bname" ng-init="bname=false; name='default value'" >