离子构建给出错误:不支持函数调用

时间:2016-10-10 12:36:17

标签: angular ionic-framework ionic2

为离子2 RC0项目执行import java.util.ArrayList; public class Student { String name; int id; public Student(String name, int id) { this.name = name; this.id = id; } public static void main(String[] anyString) { // Creating Some student objects Student s1 = new Student("Ammar", 1); Student s2 = new Student("Ahmad", 2); Student s3 = new Student("Arslan", 3); // Creating an arraylist ArrayList<Student> someList = new ArrayList<Student>(); // checking if our Array List is empty or not boolean empty = someList.isEmpty(); if (empty == true) System.out.println("ArrayList is Empty \n\n"); // adding our student class objects to our arraylist someList.add(s1); someList.add(s2); someList.add(s3); // checking if arraylist is empty or not if (someList.isEmpty()) System.out.println("ArrayList is Empty"); else // counting total members in a list System.out.printf("Our ArrayList someList has a total of %d Members \n\n", someList.size()); // geting back objects from arraylist or extracting them from list // we will display our objects to console one by one for (Student student : someList) { System.out.println(student); } } @Override public String toString() { return "Student [name=" + name + ", id=" + id + "]"; } } 时,出现以下错误:

ionic build

任何人都知道我需要做些什么才能摆脱这个错误?

我的app.modules.ts文件如下所示:

&#13;
&#13;
[13:26:17]  ngc: 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, resolving symbol AppModule in /Users/billnoble/Documents/YHistory-App3/.tmp/app/app.module.ts, resolving symbol AppModule in /Users/billnoble/Documents/YHistory-App3/.tmp/app/app.module.ts
at simplifyInContext (/Users/billnoble/Documents/YHistory-App3/node_modules/@angular/compiler-cli/src/static_reflector.js:469:23)
at StaticReflector.simplify (/Users/billnoble/Documents/YHistory-App3/node_modules/@angular/compiler-cli/src/static_reflector.js:472:22)
at StaticReflector.annotations (/Users/billnoble/Documents/YHistory-App3/node_modules/@angular/compiler-cli/src/static_reflector.js:61:36)
at _loop_1 (/Users/billnoble/Documents/YHistory-App3/node_modules/@angular/compiler-cli/src/codegen.js:53:54)
at CodeGenerator.readFileMetadata (/Users/billnoble/Documents/YHistory-App3/node_modules/@angular/compiler-cli/src/codegen.js:66:13)
at /Users/billnoble/Documents/YHistory-App3/node_modules/@angular/compiler-cli/src/codegen.js:100:74
at Array.map (native)
at CodeGenerator.codegen (/Users/billnoble/Documents/YHistory-App3/node_modules/@angular/compiler-cli/src/codegen.js:100:35)
at codegen (/Users/billnoble/Documents/YHistory-App3/node_modules/@angular/compiler-cli/src/main.js:7:81)
at Object.main (/Users/billnoble/Documents/YHistory-App3/node_modules/@angular/tsc-wrapped/src/main.js:30:16)
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:1)

您应该删除以下导入内的调用:

  

{提供:XSRFStrategy,useValue:new CookieXSRFStrategy('csrftoken',   'X-CSRFToken')}

然后转到声明factoryFunction

export function CookieXSRFStrategyFactory(http:Http) {
return  new CookieXSRFStrategy('csrftoken', 'X-CSRFToken');

}

并在您的提供中写下:

provide:XSRFStrategy, useValue: CookieXSRFStrategyFactory

答案 1 :(得分:1)

这是为了帮助以后来这里的人。在我升级Angular之后,当直接从提供程序调用{​​{3}}时,我遇到了类似的问题。

上述答案在Angular v2.4.7中对我没有任何影响,但以下情况确实如此。请注意使用CookieXSRFStrategy()来引用对象。

import { XSRFStrategy, CookieXSRFStrategy } from '@angular/http';

export function CookieXSRFStrategyFactory() {
  return new CookieXSRFStrategy('csrftoken', 'X-CSRFToken');
}

export const AppCSRF = {
  provide: XSRFStrategy,
  useFactory: CookieXSRFStrategyFactory,
};

然后,将AppCSRF列入您模块的其他提供商。

providers: [
  ...
  AppCSRF,
  ...
],