我正在尝试从另一个组件进行sidenav切换,但是当从我的父组件调用.toggle()函数时,它将引发此错误:
AppComponent.html:1错误TypeError:AppComponent.webpackJsonp.176.AppComponent.toggleNav中的this.sidenav.toggle不是函数(app.component.ts:25)
这是代码:app.component.ts
import { Component, ViewChild } from '@angular/core';
import { MaterialModule } from '@angular/material';
import { NavComponent } from './nav/nav.component';
import { SidebarComponent } from './sidebar/sidebar.component';
import { FooterComponent } from './footer/footer.component';
import { MdSidenav } from '@angular/material';
@Component({
moduleId: module.id,
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent{
title = 'CRS Management App';
@ViewChild('sidenav') sidenav:MdSidenav;
toggleNav(){
this.sidenav.toggle();
}
}
Run Code Online (Sandbox Code Playgroud)
app.component.html:
<app-nav #navbar (nav)="toggleNav()"></app-nav>
<app-sidebar #sidenav></app-sidebar>
<app-footer></app-footer>
Run Code Online (Sandbox Code Playgroud)
(nav)从app-nav组件发出。
sidebar.component.ts:
@Component({
selector: 'app-sidebar',
templateUrl: './sidebar.component.html',
styleUrls: ['./sidebar.component.scss'] …Run Code Online (Sandbox Code Playgroud) I am trying to dynamically split an array of objects into groups based on values of a property.
Here is an example of the input:
`input = [
{"name": "john", "location": "first"},
{"name": "steve", "location": "first"},
{"name": "paul", "location": "another"},
{"name": "tony", "location": "random"},
{"name": "ant", "location": "random"}
]`
Run Code Online (Sandbox Code Playgroud)
and the desired output:
`solution(input, location) = [
first: [{"name": "john", "location": "first"},
{"name": "steve", "location": "first"}],
another: [{"name": "paul", "location": "another"}],
random: [{"name": "tony", "location": "random"},
{"name": "ant", "location": "random"}] …Run Code Online (Sandbox Code Playgroud) 在 Model.insertMany 的文档中,它说当 options.ordered == true 时,该方法将在第一个错误时失败。
\n\nhttps://mongoosejs.com/docs/api.html#model_Model.insertMany
\n\n\n\n\n[options.ordered \xc2\xabBoolean\xc2\xbb = true] 如果为 true,则在遇到第一个错误时快速失败。如果为 false,将插入它可以插入的所有文档并稍后报告错误。ordered = false 的 insertMany() 称为“无序”insertMany()。
\n
可以:
\n\n或者
\n\n