question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

hide/delete underline input

See original GitHub issue

Bug

Property 'underlineRef' does not exist on type 'MdInputDirective'

However, underlineRef property exists if we log this MdInputDirective:

angularerror

Expected behavior

@ViewChild('input') input: MdInputDirective;

ngOnInit(): void {
  this.input.underlineRef.nativeElement.className = null;  // Removes the input underline 
}

What is the current behavior?

Compilation error

What are the steps to reproduce?

Link of a discussion on the issue: https://stackoverflow.com/questions/45556972/how-to-hide-delete-underline-input-angular-material

Is there anything else we should know?

Workaround
@ViewChild('input') input: MdInputDirective;

ngOnInit(): void {
  this.input['underlineRef'].nativeElement.className = null;  // Remove the input underline 
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

21reactions
willshowellcommented, Aug 24, 2017

Personally I’d opt for using css and leaving the underlineRef alone. I think the only reason it is exposed is for the datepicker to have a reference element to attach to, and I could easily see it going away or becoming internal-use-only.

I’d suggest a slight variation of your plunk:

// in global stylesheet
.mat-input-container.app-input-no-underline .mat-input-underline {
  display: none;
}
<md-input-container [class.app-input-no-underline]="!showUnderline">
  <input mdInput>
</md-input-container>

https://plnkr.co/edit/S8vHnOuzr6l6tYiMOnmi?p=preview

By adding it to a global stylesheet, you can keep view encapsulation on for your component.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 6, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to hide/delete underline input Angular Material?
In compoent do following: @ViewChild('input') input: MdInputDirective; ngOnInit(){ this.input.underlineRef.nativeElement.className = null; }.
Read more >
How To Hide/Delete Underline Input Angular Material - ADocLib
The way to remove underlines from your links is to Select your link (or if you have text inside a Button Block, an...
Read more >
How to remove underline for anchors tag using CSS?
Example 2: Use hover property to remove underline when mouse move over the anchor part.
Read more >
How to Remove and Style the Border Around Text Input Boxes ...
Use outline: none to remove the ugly border color for a form field in Chrome. Learn also how to give your own style...
Read more >
How to hide/delete underline input Angular Material - iTecNote
When input has focus it displays underline. How to hide or remove that? Seem I need to set null for underlineRef ?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found