Sei*_*ria 3 javascript placeholder angularjs
我环顾四周,找到了几个标有'ng-placeholder'的资源或类似的东西.我不能让这个工作:
<input type="text" placeholder="{{option.name}}" class="form-control" ng-switch-when="text" />
我注意到输入文档中似乎没有任何内容.我对角度很新,而这几乎没有让我感到沮丧几个小时.必须有办法做到这一点.
为什么不为ng-placeholder编写自己的指令?像这样简单的东西应该有效.你可以在你的html中调用它
<input ng-placeholder='test'>
Run Code Online (Sandbox Code Playgroud)
其中test是当前控制器中的范围变量.
.directive('ngPlaceholder', function($document) {
return {
restrict: 'A',
scope: {
placeholder: '=ngPlaceholder'
},
link: function(scope, elem, attr) {
scope.$watch('placeholder',function() {
elem[0].placeholder = scope.placeholder;
});
}
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6212 次 |
| 最近记录: |