TypeError: this.getField(...).map is not a function
See original GitHub issueUsing angular-tree-component 3.2.3.
In my template:
<tree-root *ngIf="nodes" [nodes]="nodes" class="box left"></tree-root>
In my App Component constructor:
export class AppComponent {
name = 'Angular';
nodes: any;
public constructor(private service: MyService) {
this.service.getdata().subscribe(
data => this.nodes = data,
err => console.error(err),
() => console.log('get complete')
);
As soon as my data callback returns from getting data from my service and tries to add to the nodes property, I get this:
TypeError: this.getField(...).map is not a function
at TreeNode._initChildren (http://localhost/node_modules/angular-tree-component/dist/angular-tree-component.umd.js:21686:14)
at new TreeNode (http://localhost/node_modules/angular-tree-component/dist/angular-tree-component.umd.js:21349:18)
at TreeModel.exports.TreeModel.TreeModel.update (http://localhost/node_modules/angular-tree-component/dist/angular-tree-component.umd.js:21785:28)
at executeAction (http://localhost/node_modules/angular-tree-component/dist/angular-tree-component.umd.js:670:19)
at TreeModel.res (http://localhost/node_modules/angular-tree-component/dist/angular-tree-component.umd.js:661:16)
at TreeModel.exports.TreeModel.TreeModel.setData (http://localhost/node_modules/angular-tree-component/dist/angular-tree-component.umd.js:21776:14)
at executeAction (http://localhost/node_modules/angular-tree-component/dist/angular-tree-component.umd.js:670:19)
at TreeModel.res (http://localhost/node_modules/angular-tree-component/dist/angular-tree-component.umd.js:661:16)
at TreeComponent.exports.TreeComponent.TreeComponent.ngOnChanges (http://localhost/node_modules/angular-tree-component/dist/angular-tree-component.umd.js:22585:24)
at Wrapper_TreeComponent.ngDoCheck (/TreeModule/TreeComponent/wrapper.ngfactory.js:60:18)
at View_AppComponent1.detectChangesInternal (/AppModule/AppComponent/component.ngfactory.js:45:27)
at View_AppComponent1.AppView.detectChanges (http://localhost/node_modules/@angular/core/bundles/core.umd.js:12208:18)
at View_AppComponent1.DebugAppView.detectChanges (http://localhost/node_modules/@angular/core/bundles/core.umd.js:12355:48)
at ViewContainer.detectChangesInNestedViews (http://localhost/node_modules/@angular/core/bundles/core.umd.js:12466:41)
at CompiledTemplate.proxyViewClass.View_AppComponent0.detectChangesInternal (/AppModule/AppComponent/component.ngfactory.js:197:14)
I tried adding “import ‘rxjs/add/operator/map’;” to my service and my component, but that didn’t help.
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
TypeError: this.getField(...).map is not a function #226 - GitHub
Using angular-tree-component 3.2.3. In my template: In my App Component constructor: export class AppComponent { name = 'Angular'; ...
Read more >A simple this.getfield property does not work in the debugger
TypeError : this.getfield is not a function. 1:Console:Exec. undefined. My result is first of all "undefined". When watching a little video ...
Read more >TypeError: this.getField(...).map is not a function - Bountysource
Using angular-tree-component 3.2.3. In my template: <tree-root *ngIf="nodes" [nodes]="nodes" class="box left"></tree-root>.
Read more >Angular HTTP GET with TypeScript error http.get(...).map is not ...
When the bundlers tries to eliminate the unused code (a.k.a. tree shaking ), they may decide to keep the code of the map...
Read more >TypeError: map.get is not a function in JavaScript | bobbyhadz
The "Map.get is not a function" error occurs when we call the `get()` method on a value that is not a `Map` object....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Note that root node has to be an array too.
I solved this issue by using toPromise() to return a promise instead of observable.