首页 > 解决方案 > 无法绑定到“zIndex”,因为它不是“ng2-dropdown-menu”的已知属性

问题描述

我的项目昨天运行良好。当我早上开始运行它时,它给了我这个错误。

If 'ng2-dropdown-menu' is an Angular component and it has 'zIndex' input, then verify that it is part of this module.
2. If 'ng2-dropdown-menu' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("namicUpdate">
    <ng2-dropdown-menu [focusFirstElement]="focusFirstElement"
                       [ERROR ->][zIndex]="zIndex"
                       [appendToBody]="appendToBody"
                       [offset"): ng:///TagInputModule/TagInputDropdown.html@2:23
    at syntaxError (compiler.es5.js:1694)
    at TemplateParser.parse (compiler.es5.js:12791)
    at JitCompiler._compileTemplate (compiler.es5.js:26994)
    at compiler.es5.js:26913
    at Set.forEach (<anonymous>)
    at JitCompiler._compileComponents (compiler.es5.js:26913)
    at compiler.es5.js:26800
    at Object.then (compiler.es5.js:1683)
    at JitCompiler._compileModuleAndComponents (compiler.es5.js:26799)
    at JitCompiler.compileModuleAsync (compiler.es5.js:26728)

ng2-dropdown-menu是在https://github.com/benfoley/angular2-tag-input包中。

提前致谢。

标签: angular

解决方案


你需要导入{ Ng2DropdownModule }

import { Ng2DropdownModule } from 'ng2-material-dropdown';

@NgModule({
    imports: [
        Ng2DropdownModule
    ],

同样在您需要做的组件中,

import { Ng2Dropdown, Ng2MenuItem } from 'ng2-material-dropdown';

还添加一个输入,

@Input() public zIndex = new defaults().zIndex;

还升级你的包ngx-chips


推荐阅读