我来自react世界-我非常熟悉通过react启动应用程序的基本概念
index.js
不必处理任何html或任何东西。在那些定义视图的javascript文件中,它们都通过
import
export
,在哪里
export default
意味着默认导入将是该对象,并且
允许从同一文件导入多个对象。
说了这么多,在角度上有什么不同吗?
import {Injectable} from '@angular/core';
@Injectable()
class LoggerService {
info(msg: any) {
console.log(msg);
}
warn(msg: any) {
console.warn(msg);
}
error(msg: any) {
console.error(msg);
}
}
export LoggerService;
然而,当我这样做,我的TSLint踢在我和警告我
TSLint:未使用的表达式,应为赋值或函数调用。。。
我知道我看到的每一个教程都包含了export类中的所有内容,我不习惯(这就是为什么我试图用另一种方式来做),但如果这只是角度最佳实践,那就这样吧。