components icon indicating copy to clipboard operation
components copied to clipboard

a[md-button] doesn't work without button[md-button]

Open szechyjs opened this issue 10 years ago • 5 comments

The following code doesn't properly render buttons.

<md-toolbar color="primary">
    <span>App</span>
    <a md-button color="primary" [routerLink]="['/summary']">Summary</a>
    <a md-button color="primary" [routerLink]="['/log']">View Log</a>
    <a md-button color="primary" [routerLink]="['/metric']">View Metric</a>
    <a md-button color="primary" [routerLink]="['/config']">View Config</a>
</md-toolbar>

screen shot 2016-05-06 at 4 39 46 pm

If I add a button it fixes the a[md-buttons]:

<md-toolbar color="primary">
    <span>App</span>
    <a md-button color="primary" [routerLink]="['/summary']">Summary</a>
    <a md-button color="primary" [routerLink]="['/log']">View Log</a>
    <a md-button color="primary" [routerLink]="['/metric']">View Metric</a>
    <a md-button color="primary" [routerLink]="['/config']">View Config</a>
    <button md-button>FOO</button>
</md-toolbar>

screen shot 2016-05-06 at 4 40 06 pm

Using:

  • angular: 2.0.0-rc.0
  • material: 2.0.0-alpha.4

szechyjs avatar May 06 '16 20:05 szechyjs

I'm having some trouble replicating this. Did you import MdAnchor into your TS and add it to your directives array? It sounds like it's missing. If not, a plunker or a TS file would be helpful.

kara avatar May 06 '16 21:05 kara

Importing MdAnchor as a directive solved my problem.

<md-toolbar color="primary">
    <span>App</span>
    <a md-button [routerLink]="['/summary']">Summary</a>
    <a md-button [routerLink]="['/log']">View Log</a>
    <a md-button [routerLink]="['/metric']">View Metric</a>
    <a md-button [routerLink]="['/config']">View Config</a>
</md-toolbar>

I also had to remove color="primary" else the text color was the same as the background color. Is this correct?

We should probably add something to the docs about MdAnchor.

Thanks for the help!

szechyjs avatar May 06 '16 21:05 szechyjs

We haven't yet documented MdAnchor, which is pretty confusing. Thanks for bringing it up! I added an issue: https://github.com/angular/material2/issues/399

Re: color, using md-button gives you a flat button. The color property for a flat button controls the color of its foreground text. Since your toolbar background color is set to the primary color and the button text color is set to that same primary, it is expected that it will be the same. You'll probably want to remove the color attributes from your buttons to ensure they use the default contrast color defined by the toolbar. Hope that helps! Closing this, as it doesn't seem to be a bug.

kara avatar May 06 '16 22:05 kara

angular rc1 , material 5-2 - not working for me

nadavten avatar Jun 11 '16 13:06 nadavten

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.