相关疑难解决方法(0)

@angular/material/index.d.ts' 不是模块

使用 Angular 8,在构建应用程序时,我们遇到以下错误:

app/modules/admin-module/pages/editor/editor.component.ts:6:27 - error TS2306: 
File ...node_modules/@angular/material/index.d.ts' is not a module.
Run Code Online (Sandbox Code Playgroud)

angular-material angular

164
推荐指数
8
解决办法
14万
查看次数

属性'...'没有初始化程序,并且在构造函数中没有明确赋值

在我的Angular应用程序中,我有一个组件:

import { MakeService } from './../../services/make.service';
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-vehicle-form',
  templateUrl: './vehicle-form.component.html',
  styleUrls: ['./vehicle-form.component.css']
})
export class VehicleFormComponent implements OnInit {
  makes: any[];
  vehicle = {};

  constructor(private makeService: MakeService) { }

  ngOnInit() {
    this.makeService.getMakes().subscribe(makes => { this.makes = makes
      console.log("MAKES", this.makes);
    });
  }

  onMakeChange(){
    console.log("VEHICLE", this.vehicle);
  }
}
Run Code Online (Sandbox Code Playgroud)

但在"制造"属性中我有一个错误.我不知道该怎么做...

错误

javascript typescript angular

45
推荐指数
26
解决办法
2万
查看次数

角度2 - 如何隐藏某些组件中的导航栏

我在nav.component.html中单独创建了导航栏,如何在某些组件中隐藏导航栏,例如login.component.

nav.component.html

<nav class="navbar navbar-default navbar-fixed-top navClass">
    <div class="container-fluid">
        <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed"
                        (click)="toggleState()">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>

        </div>
         <div class="collapse navbar-collapse"
              [ngClass]="{ 'in': isIn }">
          enter code here   <ul class="nav navbar-nav">
               <li class="active"><a href="#">Home</a></li>
               <li><a href="#">about</a></li>

            </ul>

        </div>
    </div>
</nav>
Run Code Online (Sandbox Code Playgroud)

html angular

20
推荐指数
3
解决办法
4万
查看次数

在组件之间展开/折叠功能

我有 2 个不同的组件,我在其中使用 Angular - Expansion Panel 进行可扩展的摘要视图。

我能够<mat-expansion-panel>成功集成到单个组件。

我需要帮助,使Component2.html作为母公司Component1.html(中expand-展开请参见下图)在此处输入图片说明

  • 组件 1 应该能够独立展开和折叠以显示数据

  • 组件 2 应该将组件 1 嵌入到自身中,所以当 Component 1 is expanded it can show its data and display remaining Child components

注意- 组件都具有兄弟关系no parent childchild - parent

组件1.html

  <div class="row">
    <div class>
      <dl class="row property_set" data-property-set-name="data">
        <mat-accordion>
          <mat-expansion-panel (opened)="doExpand = true"
                             (closed)="doExpand = false">
          <mat-expansion-panel-header>
            <mat-panel-title>
        <dt class="col-sm-4 record_property">data</dt>
      </mat-panel-title>
      <mat-panel-description>
        <dd class="col-sm-8 record_property_value data_name" id="{{genId(data.name)}}">
          <inline-misal-edit …
Run Code Online (Sandbox Code Playgroud)

parent-child angular-material angular mat-expansion-panel

6
推荐指数
1
解决办法
282
查看次数