作为angular的初学者,我在尝试通过angular-cli构建我的应用程序时遇到了一个问题。
在遵循了本教程之后:
我的appModule看起来像:
...
providers: [
{ provide: HttpService, useFactory: (backend: XHRBackend, options: RequestOptions) => {
return new HttpService(backend, options); },
deps: [XHRBackend, RequestOptions]}
]
...
Run Code Online (Sandbox Code Playgroud)
构建它时,我得到:
Error: Error encountered resolving symbol values statically. Function calls are
not supported. Consider replacing the function or lambda with a reference to an
exported function (position 63:39 in the original .ts file), resolving symbol Ap
pModule in ../angular/app/src/app/app.module.ts
at positionalError (..\angular\app\node_modules\@angular\compiler-c
li\src\static_reflector.js:595:18)
Run Code Online (Sandbox Code Playgroud)
当我使用ng serve该应用程序时,没有任何问题。
我目前正在学习数据结构,尝试在 TS 中实现 LinkedList 时遇到了几个问题。我添加了几种方法,但虽然它似乎有效,但输出确实很奇怪。
我的问题在评论中。
我的代码:
function LinkedList () { //why doesn't fat arrow syntax work??
//ie. let LinkedList = () => {...this.append = () => {}...}
// prints out TypeError: t.append is not a function
let Node = (elem) => {
this.elem = elem;
this.next = null;
}
this.head = null;
this.len = 0;
this.append = (elem) => {
let node = new Node(elem);
let current;
if(this.head === null){
this.head = node;
} else {
current = this.head; …Run Code Online (Sandbox Code Playgroud)