I'm using Angular Material autocomplete chips (https://material.angular.io/components/chips/examples). So there is placeholder which goes up after u click on field. Is it possible to delete this placeholder, so then i can use default placeholder w/o angular material styles ? I've tried to find it inside dev tools, but i couldn't.
相关问题
- Angular RxJS mergeMap types
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- How to update placeholder text in ng2-smart-table?
- How to instantiate Http service in main.ts manuall
- Angular: ngc or tsc?
相关文章
- angular脚手架在ie9+下兼容问题
- angular 前端项目 build 报错 "Cannot find module 'le
- Angular Material Stepper causes mat-formfield to v
- After upgrade to Angular 9 cannot find variable in
- is there any difference between import { Observabl
- Suppress “Circular dependency detected” suppress w
- How can you get current positional information abo
- Angular material table not showing data
if you would like to customise your Angular material components and provide your own stylings for the mat-chips placeholder, I have the following suggestions. You may use one of them.
1) Overwrite the classes on your main
style.css
(or style.scss, whichever you are using). If you are wondering, it is the one that is on the same directory level as your index.html, main.ts, package.json, etc. You might need to add the!important
declaration2) Use
ViewEncapsulation:None
. This removes all encapsulation, such that CSS rules will have a global effect.On your component.ts, you will need to import
ViewEncapsulation
, followed by selecting None when you provide the definitions for encapsulationAnd on your component.css,
3) Customising the
MatPlaceholder
directive (overriding the Angular Material placeholder css without using !important) [EDIT]According to the Angular Material Form Field API, it turns out the placeholder directive is accessible once we have imported that module.
On your component.html, include the
<mat-placeholder>
directive with a custom class within your<mat-form-field>
, and remove placeholder from the<input>
within the<mat-chip-list>
And on your component.css, define the
.placeholder
class (assigned to the mat-placeholder directive) with your custom CSS properties.You can add
[floatLabel]="'never'"
so when enter chip, placeholder will not go up,and not be visible.Add it to
mat-form-field