Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度材质:如何右对齐matInput占位符?_Angular_Angular Material - Fatal编程技术网

Angular 角度材质:如何右对齐matInput占位符?

Angular 角度材质:如何右对齐matInput占位符?,angular,angular-material,Angular,Angular Material,我有一个简单的代码: <body style="direction: rtl; text-align: right"> <mat-form-field> <input matInput placeholder="Wanna be rtl" /> </mat-form-field> </body> 但不管我想做什么,占位符都是从左到右的。有没有办法将其向右对齐?在表单字段上使用文本对齐

我有一个简单的代码:

<body style="direction: rtl; text-align: right">
    <mat-form-field>        
        <input matInput placeholder="Wanna be rtl" />
    </mat-form-field>
</body>


但不管我想做什么,占位符都是从左到右的。有没有办法将其向右对齐?

在表单字段上使用
文本对齐将起作用:请参阅工作

此解决方案将占位符和输入文本向右对齐:

<body>
    <mat-form-field style="text-align: right">        
        <input matInput placeholder="Wanna be rtl" />
    </mat-form-field>
</body>
结果: 使用CDK中的模块:

import {BidiModule} from '@angular/cdk/bidi';

...

<body dir="rtl">
    <mat-form-field>        
        <input matInput placeholder="I am RTL" />
    </mat-form-field>
</body>
从'@angular/cdk/bidi'导入{BidiModule};
...

过了一段时间,我遇到了
mat form字段的sas,我发现如果
mat form字段的父项具有
dir=“rtl”
属性,它将充当rtl:

<body dir="rtl">
   <mat-form-field>        
       <input matInput placeholder="I am rtl" />
   </mat-form-field>
</body>

<body dir="rtl">
   <mat-form-field>        
       <input matInput placeholder="I am rtl" />
   </mat-form-field>
</body>