I want the component to set the templateUrl
with a variable, but it doesn't work.
@Component({
selector: 'article',
templateUrl: '{{article.html}}',
styleUrls: ['styles/stylesheets/article.component.css']
})
export class ArticleComponent implements OnInit {
constructor(private route: ActivatedRoute, private articleService: ArticleService) { }
articleArray = this.articleService.getArticles();
article: Article;
ngOnInit(): void {
this.route.params.forEach((params: Params) => {
let headline = params['headline'];
this.article = this.articleService.getArticle(headline)
});
}
}
Every where I look, I can only see solutions for Angular 1.X, It's really frustrating. I looked into the browser console and figured out that {{article.html}} isn't even resolving. It's reading as it is. It works totally fine when I set the path myself, so I know that the problem isn't anywhere but here.
See Question&Answers more detail:os