简体   繁体   English

模态弹出窗口中的垫树节点

[英]Mat tree node in modal popup

In my application I want to create a modal pop up. 在我的应用程序中,我想创建一个模式弹出窗口。 I get errors when I refer to a component with mat tree . 当我用mat tree引用组件时会出错。 In console I see the following errors Could not find a tree control for the tree and multiple There can only be one default row without a when predicate function. 在控制台中,我看到以下错误Could not find a tree control for the tree和多个Could not find a tree control for the tree There can only be one default row without a when predicate function. .

The modal works if I refer to another component without mat tree . 如果我引用的是另一个没有mat tree组件,则该模态有效。

I've used the examples from angular material and I have the same issue in my application. 我使用了有角度的材料中的示例,在我的应用程序中也遇到了同样的问题。 I only see a button for the pop up modal. 我只看到弹出模式的按钮。 Click on Pick One button to see the pop up. 单击“ Pick One按钮以查看弹出窗口。

https://stackblitz.com/edit/angular-uzh1tt https://stackblitz.com/edit/angular-uzh1tt

In dialog overview example component modal works with dialog-overview-example-dialog selector and template url . 在对话框概述示例组件模态中,可以使用dialog-overview-example-dialog selector and template url It does not work with tree flat . 它不适用于tree flat

I want to see the modal pop up with mat tree with all the nodes expanded. 我想看到带有扩展所有节点的垫树的模态弹出窗口。

This has nothing to do with your actual tree control, but how you were trying to access it. 这与您的实际树控件无关,但与您尝试访问它的方式无关。

Change your code to this 将您的代码更改为此

const dialogRef = this.dialog.open(TreeFlatOverviewExample, {
      width: '250px'
    });

and import { TreeFlatOverviewExample } from './tree-flat-overview-example'; import { TreeFlatOverviewExample } from './tree-flat-overview-example';

You were trying to open a component that you had defined at the bottom of your code instead of the TreeFlatOverviewExample. 您试图打开在代码底部定义的组件,而不是TreeFlatOverviewExample。 In that component you were trying to load in the html of your tree component, which did in fact work, but it ONLY loaded the html. 在该组件中,您尝试加载树组件的html,实际上确实可以,但是它仅加载了html。 You needed to load the associated typescript as well. 您还需要加载关联的打字稿。 This is why your error messages were saying it couldn't find the typescript variable treeControl. 这就是为什么您的错误消息说找不到打字稿变量treeControl的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM