javascript - 使用 ng-style 更改输入占位符的颜色
问题描述
我的控制器中有 $scope 变量来定义我想嵌入到我的 html 代码中的输入占位符的颜色。
$scope 变量定义如下:
$scope.primaryColor={"color":colorVar}; //colorVar is the color in hex
color var 具有动态值,我想在输入 html 标记上使用 ng-style 来设置输入内占位符的颜色属性。
<input required name="email" ng-model="email" placeholder="hi@whatever.com" ng-style="">
我知道我无法通过内联 css 更改占位符颜色属性。有没有办法可以使用 ng-style 或任何其他方法将颜色变量传递给 css?
我怎样才能做到这一点?
解决方案
将 ng-class 添加到供应商前缀就可以了
HTML:
<input type="text" placeholder="Quick test" required=""
class="ng-pristine ng-invalid ng-invalid-required ng-touched">
文案:
.ng-touched::-webkit-input-placeholder { color: red; }
.ng-untouched::-webkit-input-placeholder { color: #cccccc; }
推荐阅读
- flutter - 从 Firebase.initializeApp() 获取令牌
- regex - 可选地匹配正则表达式的一部分?
- xcode - 安装 react-native-vector 图标后无法构建 React Native 应用程序
- gis - QGIS中克里金法的预测输出不起作用
- django - 为什么我不能在 jinja 中使用括号或冒号或许多其他字符?
- spring-boot - 我如何通过spring security oauth2客户端使用的ajax登录
- python - 如何使用Regex python从单词的两侧删除双引号
- android - Android 11 图像保存问题
- visual-studio-code - VS 代码未解决的导入
- macos - 无法使用 Apple M1 芯片将 Flutter 安装到 macOS Big Sur