Angular 2在@View中使用templateUrl

时间:2016-03-30 21:42:10

标签: javascript angularjs angular

我正在尝试使用@View中的templateUrl,但它只是不允许它。

如果我按照这种方式行事,那就可以了:

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

@Component({
    selector: 'my-app',
    templateUrl: './app/templates/app.component.html'
})

export class AppComponent { }

...但是当我尝试这个时,它会破坏:

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

@Component({
    selector: 'my-app',
})
@View({
   templateUrl: './app/templates/app.component.html'
})

export class AppComponent { }

这是不允许的?如果它被允许,我错过了什么?

1 个答案:

答案 0 :(得分:2)

@View已在最新版本中弃用,因此您无法使用它。只有Component才能容纳所有选项。

Per @ Eric的评论,@View元数据装饰器在beta.10发布中已被删除