Reputation: 2936
In a component I have something like this:
<a class="btn" [attr.href]="movie.imdbUrl" target="_blank" >IMDb</a>
but when I click on it nothing happens.
movie.imdbUrl
points to "http://www.imdb.com/title/tt2305051/" and I thought it would be equivalent to:
<a class="btn" href="http://www.imdb.com/title/tt2305051/" target="_blank" >IMDb</a>
What am I missing?
Upvotes: 2
Views: 4299
Reputation: 1542
Thix example work for me :
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `
<a class="btn" [attr.href]="movie.imdbUrl" target="_blank" >IMDb</a>
`
})
export class AppComponent {
movie = {
imdbUrl: "http://www.imdb.com/title/tt2305051/"
}
}
Are you sure you have defined the movie object correctly in your Component ?
Upvotes: 1
Reputation: 1437
Maybe not the most elegant way, but definitelly should work:
How to redirect to an external URL in Angular2
window.location.href = '...';
Upvotes: 1