我是AngularJS的新手,我正在通过this链接,我很好奇使用ng-bind在文本框控件上做实验。但它不起作用。
<html>
<title>AngularJS First Application</title>
<body>
<h1>Sample Application</h1>
<div ng-app="">
<p>Enter your Name: <input type="text" ng-model="name"></p>
<input type ="text" ng-bind="name" />
</div>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</body>
</html>如何使用ng-bind填充文本框?
发布于 2015-03-24 16:06:20
因为,ngBind属性告诉Angular用给定表达式的值替换指定元素的文本内容,并在该表达式的值更改时更新文本内容,您将无法绑定到输入框:
<input type ="text" ng-bind="name" />您可以改为使用ng-value
<input type="text" ng-value="name" />或者您可以使用value属性中的模型填充您的输入框。
<input type="text" value="{{name}}" />查看此codepen
https://stackoverflow.com/questions/29227480
复制相似问题