为什么templateUrl不起作用?

问题描述 投票:3回答:2

为什么templateUrl在角度2中不起作用。当我使用模板时,它起作用。它不起作用..这是我的代码

http://plnkr.co/edit/WI4gK2vbaj4OUX5ImJor?p=preview

import {Component,View} from 'angular2/core';

@Component({
    selector: 'my-app',
//  template: '<div (click)="onclck()">hello</div>'
})

@View({
  templateUrl: 'home/home.html'
});
export class AppComponent {

  onclck(){
    alert('--')
  }

}
angular angular2-routing angular2-template
2个回答
8
投票

您在@View装饰器和export class AppComponent中的app/script.ts之间有分号。只需将其删除即可。


0
投票

可能已关闭自动保存,只需尝试保存home.component.html,home.component.ts和app.module.ts文件

© www.soinside.com 2019 - 2024. All rights reserved.