Wijmo not working with released angular2

945 views Asked by At

I am using wijmo 5 with angular 2 released version.But after setting up all the file and requirement with wijmo when a write code in angular 2 app shows error like code line and error are following

data: wijmo.collections.CollectionView; error TS2503: Cannot find namespace 'wijmo'.

this.data = new wijmo.collections.CollectionView(new wijmo.collections.ObservableArray(data));

error TS2304: Cannot find name 'wijmo'. error TS2304: Cannot find name 'wijmo'.

1

There are 1 answers

0
RMD On BEST ANSWER

I'm making a few assumptions here:

  1. You used the Angular CLI to create your A2 project
  2. You used NPM to bring in the Wijmo library into your project

If so, then within the module where you are using Wijmo, you need to ensure you import the necessary Wijmo modules, ie:

    ...

    import { WjCoreModule } from 'wijmo/wijmo.angular2.core';
    import { WjGridModule } from 'wijmo/wijmo.angular2.grid';
    import { WjInputModule } from 'wijmo/wijmo.angular2.input';

    ...


    @NgModule({
      declarations: [AppComponent],
      imports: [
       ...
        WjCoreModule,
        WjGridModule,
        WjInputModule,

       ...
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }

Then within the component you are working on, ensure you import the Collection view, ie:

...

import { CollectionView } from 'wijmo/wijmo';


@Component({
    selector: 'app-test',
    templateUrl: './test.component.html'
})
export class TestComponent  {

    data : CollectionView();
...

As a final note - you shouldn't need to wrap your data in an Wijmo ObservableArray prior to passing it into the CollectionView - just pass the data array into the CollectionView directly.