【发布时间】:2016-03-29 08:46:45
【问题描述】:
我想创建一个text input 将其链接到作用域中的一个变量。但我不希望placeholder 显示任何内容。然而这个变量在范围内的内容继续显示。为什么?
var app = angular.module('example', []);
app.controller('MainCtrl', function($scope) {
$scope.hello = 'hello';
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="example" ng-controller="MainCtrl">
<input type="text" ng-model="hello" placeholder="">
</body>
【问题讨论】:
-
Angular 将
$scope.hello放入<input >元素值中,与占位符无关。能否请您说的更具体些。 -
我在作用域中有一个变量,我想编辑它。在这种情况下,我希望能够使用输入文本将“hello”更改为“hello123456”
-
对不起,再次完全不清楚您为什么似乎无法做到这一点。
-
可以,但无法清除 html 页面上的“输入”元素。我希望它不包含任何内容。实际上它显示了 $scope.hello 的内容
标签: angularjs angularjs-scope placeholder angular-ngmodel