[英]placeholder not working on text-field input
I'm a newbie in Angular, so my apologies in advance for any silly mistakes.我是 Angular 的新手,所以我提前为任何愚蠢的错误道歉。 I have defined a textField input through a directive in Angular:
我已经通过 Angular 中的指令定义了一个 textField 输入:
.directive('textField', function () {
return {
restrict: 'E',
scope: true,
require: 'ngModel',
template: '{{start}}<span class="text-field-cursor">{{end}}</span>',
controller: 'TextFieldController',
link: function (scope, elem, attrs, ngModel) {
scope.keyboardOptions.limitTo = parseInt(attrs.limitTo);
scope.keyboardOptions.caps = _.has(attrs, 'caps');
scope.model = ngModel;
elem.bind('click', function () {
scope.openKeyboard();
});
elem.on('$destroy', function clickDestroyElement() {
elem.unbind();
});
}
};
})
Then, on my HTML, I wrote然后,在我的 HTML 上,我写了
<text-field class="text-field" data-t-username focusable request-focus="true" ng-class="{ 'is-focused': (focused || active), 'is-active': active }" ng-model="data.username" placeholder='Enter your username here' limit-to="32"></text-field>
However, the placeholder is not being visualized on the web page.但是,占位符并未在网页上可视化。 What am I doing wrong?
我究竟做错了什么?
In your directive, the template isn't an input.在您的指令中,模板不是输入。 So the placeholder can't work.
所以占位符不能工作。
You can change span to input or other directive who work with placeholder.您可以将跨度更改为输入或其他使用占位符的指令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.