user91579631 user91579631 - 26 days ago 6
AngularJS Question

Hyperlink on angular material button does not cause browser to jump to that link

I am using angular material on angularjs v1.

I am having problems with a simple menu bar using angular material. Here is the html code for the menu bar;

<md-toolbar layout="row" class="md-whiteframe-z3" style="padding: 0px;margin:0px;float: left;">
<h2>Test page</h2>
<md-button href="Data1.html">Data1</md-button>
<md-button href="Data2.html">Data2</md-button>
</md-toolbar>


enter image description here

When I click on
Data1
button, the browser URL changes to "http://127.0.0.1/test-site/webroot/app/Data1.html" but the browser does not go to that webpage. I have to manually refresh the page to force the browser to go to that webpage.

How can I get the browser to go to that page when the button is pressed?

Answer

Use ng-href like this

<div>
 <md-button ng-href="{{googleUrl}}" target="_blank">Go to Google</md-button>
</div>

DEMO