nesting md-grid-tile into md-button not working (Angular Material)

筅森魡賤 提交于 2019-12-24 16:11:29

问题


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>


来源:https://stackoverflow.com/questions/35612498/nesting-md-grid-tile-into-md-button-not-working-angular-material

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!