Getting Error while implementing AspectJs in angular8
vidyavikasmishra opened this issue · comments
I am trying to implement aspectjs with Angular 8. I've added below code but while running the application I am getting below error.
Uncaught Error: Unexpected value 'result' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@component annotation.
at syntaxError (compiler.js:2175)
at flattenAndDedupeArray.forEach (compiler.js:19710)
at Array.forEach ()
at CompileMetadataResolver.getNgModuleMetadata (compiler.js:19692)
at JitCompiler.loadModules (compiler.js:25402)
at JitCompiler.compileModuleAndComponents (compiler.js:25385)
at JitCompiler.compileModuleAsync (compiler.js:25347)
at CompilerImpl.compileModuleAsync (platform-browser-dynamic.js:216)
at compileNgModuleFactory__PRE_R3 (core.js:31350)
at PlatformRef.bootstrapModule (core.js:31655)
Below is the code which I am using to implement aspectjs.
aspectjs.ts code:
`import {beforeMethod, afterMethod, Metadata} from 'aspect.js';
import { Injectable } from '@angular/core';
@Injectable()
export class LoggerAspect {
public static loggerService:LoggerService;
@beforeMethod({
classNamePattern: /^.*/,
methodNamePattern: /^.*/
})
static invokeBeforeMethod(meta:Metadata):void {
let message:string = `method: ${meta.method.name}, args: ${meta.method.args.join(', ')}`;
console.log(message);
}
}
export class LoggerService{
value:string
}`
AppModule Code:
export class AppModule { constructor(private loggerService:LoggerService) { LoggerAspect.loggerService = loggerService; } }
component.ts code:
`import { Component, Injectable } from '@angular/core';
import { Wove } from "node_modules/aspect.js-angular";
@wove()
@component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
}
`
When I am removing @wove from component.ts then application is working fine however getting error when adding it again.
I've gone through #29. but was not able to resolve it.
Any help or guidance will be appreciated.
Thanks