Sql*_*ser 6 javascript angular
Angular 4支持以下语法
var HelloComponent = ng.core
Component({
selector: 'hello-cmp',
template: 'Hello World!',
viewProviders: [Service]
.Class({
constructor: [Service, function (service) {
},`
});
Run Code Online (Sandbox Code Playgroud)
在Angular 5中,Class缺少任何人都可以使用ES5语法提供Angular 5目前我无法切换ES6所以请避免使用该建议.如果切换到ES6是唯一的方法,那么我将坚持到现在的角度4
您需要在组件类函数上使用静态属性annotations
,如下所示:parameters
function Service() {}
function AppComponent(service) {
console.log(service);
}
AppComponent.prototype.ngOnInit = function() {
console.log('test ngOnInit');
};
AppComponent.annotations = [
new Component({
selector: 'my-app',
template: '<h1>Example of Angular 5.0.5 in ES5</h1>',
viewProviders: [Service]
})
];
AppComponent.parameters = [ Service ];
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
825 次 |
最近记录: |