2017-12-31 103 views
7

-aot 옵션 (ng build -aot)으로 앱을 작성하려고합니다. 나는이 호출이 필요하지만장식 자에서 함수 호출이 지원되지 않습니다

ERROR in Error during template compile of 'MyComponent' 
    Function calls are not supported in decorators but 'classLogger' was called in 'cLog' 
    'cLog' calls 'classLogger'. 

나는 내가 그것을 작동하도록 코드를 변경해야 하죠 어떻게 생각을하지 않습니다 나는 다음과 같은 오류가있어.

export function classLogger(_classOptions?) { 
    const myLogger = new MyLogger(); 
    myLogger.options = Object.assign({}, defaultClassOptions, _classOptions); 

    return myLogger.loggerCB; 
} 

// export function clog(options = defaultClassOptions): Function { 
export function cLog(options?): Function { 
    return loggingEnabled ? classLogger(options) : emptyClassDecorator(); 
} 

P. 클래스 데코레이터는 데코레이터 패치 콜백으로 전송되어야하는 옵션을 취합니다.

+0

는 각도/CLI 1.6.8이 문제를 해결 @ ... – zhekaus

답변

0

또한이 문제가 발생했습니다. 내 상황에서는 BusyConfig 매개 변수를 무시하고 싶습니다. 앱이 ng serve과 제대로 작동하지만 생산을 위해 앱을 빌드하고자 할 때 Function calls are not supported in decorators but ... 예외가 발생합니다.

내 솔루션은 다음과 같은있다 : ng build --prod --aot

+0

귀하의 솔루션은 아무것도 해결되지 않는 것처럼 보이는 ng build --prod --aot=false

The Angular Ahead-of-Time (AOT) compiler converts your Angular HTML and TypeScript code into efficient JavaScript code during the build phase before the browser downloads and runs that code.

ng build --prod은 동일합니다. 나는 특히 AOT를 사용하고자하는 문제를 보았다. AOT는 생산에 필수적입니다. – zhekaus

관련 문제