I am trying to run a unit test in angular. But I am getting the below error message. It is not throwing during compilation process and my application works fine as expected but this error is thrown only when the unit testing is carried out.
Error message: Template parse error,Cant bind to ngxrow since it is not a known property of div. <div [ERROR ->]ngxcol="{{newwidth}}">
I am not sure if the error is due to assigning value using interpolation {{}}.Is there anyway I can fix this. Trying to find a solution for past 2 days Below is my partial code:
component.html
<div ngxlayout="grid>
<div ngxrow>
<div ngxcol={{newwidth}}>
html core logic implemented
</div>
</div>
</div>
component.ts
export class AppComponent {
newwidth:any="30"
constructor(){}
}
I am not getting error if i directly assign the width as 30 in the ngxcol property directly but issue happens only if the value 30 is assigned using interpolation.
CodePudding user response:
Well, such happens (sometimes/usually) when a developer forgets to import the module of library ( error message : Cant bind to ngxrow since it is not a known property of div - which means "angular doesn't know 'ngxrow' attribute of 'normal' HTMLDivElement, (so that means that, You probably using some library (which exports those directives 'ngxrow' ...)) he wishes to use (module, containing directives: ngxlayout, 'ngxrow' ...) ... when test being bootstraped (testBed creates module for test) -> You need to import the module too .. see as an example: https://github.com/ngx-dummy/accordion-simple/blob/master/projects/@ngx-dummy/accordion-simple/src/lib/accordion-item.component.spec.ts#L33 )
