How to use templateUrl in Angular 2 directive

Viewed 10021

How do I add a html template to a directive? Here is a sample code which does not work :

import { Directive } from '@angular/core';

@Directive({
selector: '[master-side-bar]',
templateUrl : 'master-side-bar.html' })

export class MasterSideBar {

constructor() {

console.log('Hello MasterSideBar Directive');   

}

}

I get the following error :

Argument of type '{ selector: string; templateUrl: string; }' is not assignable to parameter of type 'Directive'. Object literal may only specify known properties, and 'templateUrl' does not exist in type 'Directive'.

2 Answers
Related