nesting md-grid-tile into md-button not working (A

2019-08-09 10:16发布

问题:

I have made a md-grid-list with md-grid-tiles, and I want to make each one a link. I tried wrapping each tile in a md-button but this makes the element disappear.

It doesn't have to be an md-button, it could be a simple anchor tag, but I can't seem to resolve this either way.

Any help would be appreciated.

My code:

   <md-grid-list>

      <md-button>
         <md-grid-tile>
            <img class="crest" src="img/afc-bournemouth.png">
            <md-grid-tile-footer layout-align="center center">Bournemouth</md-grid-tile-footer>
        </md-grid-tile>
     </md-button>

   </md-grid-list>

回答1:

Why not doing this:

   <md-grid-list>
    <a class="md-grid-tile" href="http://google.com" target="_blank">
        <img class="crest" src="img/afc-bournemouth.png" />
        <md-grid-tile-footer layout-align="enter center">Bournemouth</md-grid-tile-footer>
    </a>
</md-grid-list>


回答2:

I ran into a similar issue, but I ended up just using CSS to solve the issue.

<md-grid-tile>
    <a href="{{item.url}}" style="min-width: 100%; max-width: 100%; width: 100%; min-height: 100%; max-height: 100%; height: 100%;">
        <md-icon class="material-icons" style="font-size: 2.5em; position: absolute; top: 10px; left: 10px;">{{item.icon}}</md-icon>
        <md-grid-tile-footer>
            <span layout="column" style="padding-left: 5px;"></span>
            <span layout="column" style="margin-left: 5px;" class="xs-list-item-text">
                {{item.abbreviation}}
           </span>
        </md-grid-tile-footer>
    </a> 
</md-grid-tile>