标签: angular6

带有面包屑导航的角度和材质多级菜单无法正常工作

我正在使用 Angular 6 和 Angular Material 6。在这里,我尝试使用面包屑创建多级菜单。我已经正确使用了多级菜单,但无法使用选定的面包屑导航菜单。当我单击选定的面包屑时,菜单无法正确组织。

我的演示链接:stackblitz 链接在这里

breadcrumbs angular-material angular angular6 angular-material-6

0
推荐指数
1
解决办法
2万
查看次数

无法绑定到“ngModelOptions”,因为它不是 Angular 6 中“input”的已知属性

这是我的 HTML:

<nz-form-item nzFlex [formGroup]="hulkForm">
   <nz-form-label [nzSpan]="7" [nzFor]="hulkColumn.column" 
        [nzRequired]="hulkColumn.require">{{hulkColumn.lable}}</nz-form-label>
   <nz-form-control [nzSpan]="17">
   <input nz-input 
       placeholder={{hulkColumn.placeholder}} 
       [formControlName]="hulkColumn.name"
       [(ngModel)]="hulkColumn.model"
     [ngModelOptions]="{updateOn: 'blur'}"
     name="{{hulkColumn.name}}"
        *ngIf="hulkColumn.type!=='number'"
       >
 </nz-form-control>
</nz-form-item>
Run Code Online (Sandbox Code Playgroud)

这是Chrome中的错误:

这是 app.module.ts:

import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {HashLocationStrategy, LocationStrategy} from '@angular/common';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {HttpClientModule} from '@angular/common/http';
import {NgZorroAntdModule, NZ_I18N, zh_CN} from 'ng-zorro-antd';
import {registerLocaleData} from '@angular/common';
import zh from '@angular/common/locales/zh';

import {AppRoutingModule} from './app-routing.module';
import {AppComponent} from './app.component';


registerLocaleData(zh);

@NgModule({
  declarations: [
  AppComponent,
  ... …
Run Code Online (Sandbox Code Playgroud)

antd angular angular6 ng-zorro-antd

0
推荐指数
1
解决办法
7269
查看次数

Angular 6 - 动态填充表格

我正在尝试动态填充表格,但无法弄清楚为什么这不起作用!

在这里,我得到了我的 json,我将对象数组保存在 customerArray 中。

export class AllCustomersComponent implements OnInit {
customerArray: any;


    constructor(private http : HttpClient ) {}

    ngOnInit() {
         this.http.get('http://www.mocky.io/v2/5be715ce2e00008a0016945e')
        .subscribe((data) => {
           this.customerArray = data;
          console.log(customerArray);
      }
    }
}
Run Code Online (Sandbox Code Playgroud)

在这里,我试图用上述数组填充表格。

<table class="table">
        <thead>
          <tr>
            <th scope="col">First</th>
            <th scope="col">Last</th>
            <th scope="col">Age</th>
            <th scope="col">Edit</th>
            <th scope="col">Delete</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>Mark</td>
            <td>Otto</td>
            <td>46</td>
            <td><i class="fas fa-edit"></i></td>
            <td><i class="fas fa-trash-alt"></i></td>
          </tr>
          <tr>
            <td *ngFor="let customer of customerArray">{{customer}}</td>
          </tr>
        </tbody>
      </table>
Run Code Online (Sandbox Code Playgroud)

但我的表只是呈现这个:

[object Object] [object Object] [object Object] [object Object] [object …
Run Code Online (Sandbox Code Playgroud)

html-table ngfor angular6

0
推荐指数
1
解决办法
4591
查看次数

'employee[] 类型不存在属性 'emp' - Angular 6 ng serve --prod

运行命令 ng serve 工作正常,因为 ng serve --prod 显示错误

ERROR in src\app\employee\employee.component.html(12,9): : Property 'emp' does not exist on type 'employee[]'.
src\app\employee\employee.component.html(23,9): : Property 'emp' does not exist on type 'employee[]'.
src\app\employee\employee.component.html(36,9): : Property 'emp' does not exist on type 'employee[]'.
Run Code Online (Sandbox Code Playgroud)

员工.component.html

    <h2 mat-dialog-title>Edit details</h2>
<div mat-dialog-content>
  <form
    fxLayout="column"
    [formGroup]="editForm"
    #f="ngForm">
  <div class="input-row">
      <mat-form-field fxFlex>
        <mat-label>Id</mat-label>
        <input readonly 
        value="{{data.emp.id}}"
          matInput #id disabled
          formControlName="id"
          required/>
      </mat-form-field>
    </div>
    <div class="input-row">
      <mat-form-field fxFlex>
        <mat-label>Name</mat-label>
        <input 
        value="{{data.emp.name}}"
          matInput #name
          placeholder="Email"
          formControlName="name"
          required/>
      </mat-form-field>
    </div>

    <div …
Run Code Online (Sandbox Code Playgroud)

data-binding angular-material2 angular angular6

0
推荐指数
1
解决办法
744
查看次数

ngFor 中可迭代的两种方式绑定

我正在使用ngFor创建一个包含可点击图标的项目列表。
当我点击一个图标时,它会调用一个函数来更新后端的变量,成功时,我希望图标改变颜色。

如何“双向”绑定可迭代变量,obj以便当我在控制器中修改它时,它会反映在模板中?

模板:

<ion-item *ngFor="let obj of contactList | separator  " 
(click)="show_memories(obj.key, obj.bookName)" class="task-snoozed" no-lines>
    <button ion-button icon-only clear 
   (click)="$event.stopPropagation(); sendChangeState(obj, 'toBe', obj.toBeAlerted)">
        <ion-icon name="arrow-dropleft-circle" size="large" 
        [color]="obj.toBeAlerted ? 'primary' : 'gray-light'"></ion-icon>
    </button>

</ion-item>
Run Code Online (Sandbox Code Playgroud)

控制器:

sendChangeState(contact:any, alertType:string, bool:boolean){

    this.firestoreService.changeAlertState(this.userId, contact.key, alertType, bool)
    .then(() => {
        //update the icon color here:
        contact.toBeAlerted = !contact.toBeAlerted; 
    });     
}
Run Code Online (Sandbox Code Playgroud)

编辑 contactList 是一个像这样的对象: 在此处输入图片说明

ionic-framework angular angular6

0
推荐指数
1
解决办法
114
查看次数

更改事件未在角度 6 中触发

嗨,我正在调用方法 onchange 事件,但对于日历输入,它没有得到应用。下面是代码。[(change)="makeDirty()"]。它适用于描述文本框,但不适用于日期选择器文本框。

    <div class="form-group mb-10">
      <label class="formLabel">Description</label>
      <input type="text" (change)="makeDirty()" class="form-control bg-grey" [(ngModel)]='description' [ngModelOptions]="{standalone:true}">
    </div>

    <div class="form-group mb-10">
        <label class="formLabel">Period</label>
        <input type="text" (change)="makeDirty()" placeholder="select start date and end date" class="form-control bg-grey" #dp="bsDaterangepicker"
          bsDaterangepicker [(ngModel)]="bsRangeValue" [placement]="'top'" [outsideClick]="false" [bsConfig]="{  showWeekNumbers:false,containerClass: 'theme-dark-blue',rangeInputFormat: 'DD/MM/YYYY' }"
          formControlName="Period">
        <span class="glyphicon glyphicon-calendar glyicon" (click)="dp.toggle()" [attr.aria-expanded]="dp.isOpen"
          value="Toggle" style="top:36px"></span>
        <div class="alert  alert-danger" *ngIf="formGroup.get('Period').dirty && formGroup.get('Period').errors && formGroup.get('Period').errors.ageRange ">
          Date range selected is invalid
        </div>
      </div>
Run Code Online (Sandbox Code Playgroud)

angular angular6

0
推荐指数
1
解决办法
3737
查看次数

s3 HTTP post 请求工作但不返回响应(Angular 6)

我正在 Angular 6 中为我的公司构建一个媒体上传器,并在 s3 中将文件加载到我们的存储桶中。到目前为止,文件已成功上传并显示在 s3 控制台中,但 POST 请求始终返回“null”,即使它有效。

我想取回响应数据,因为我正在尝试跟踪上传进度,以在 UI 中显示用户。但是我无法从空响应中获取任何事件。

这是当前工作代码的样子。当我添加一个 console.log 并检查响应时它是“空”。我做错了什么,还是 s3 是这里的问题?

upload(url: string, data: any) {
  const options = { reportProgress: true };

  return this.http.post(url, data, options)
    .map((response: Response) => response);
}
Run Code Online (Sandbox Code Playgroud)

amazon-s3 angular angular-httpclient angular6

0
推荐指数
1
解决办法
423
查看次数

下拉列表默认值不显示 Angular-6

我正在尝试将数组绑定到列表中。绑定部分工作正常。但未显示下拉的默认值。最初数组没有任何值。

代码

<select (change)="select($event)" [(ngModel)]="drp_selectedValue" >
                    <option value ="">Select.....</option>
                    <option *ngFor="let list of dataList?.length > 0 " (click)="select(list)" [ngValue]="list">{{list.name}}</option>

                </select>
Run Code Online (Sandbox Code Playgroud)

目前我的列表显示如下

在此处输入图片说明

我还尝试检查 dataList 长度并放置 value="" ,但不起作用。我的代码有什么问题?

angular angular-forms angular6

0
推荐指数
1
解决办法
1420
查看次数

Angular:在使用 HttpClient、Observable 和异步管道加载 http 数据时执行工作

我在 angular 6 应用程序中使用 HttpClient 来加载数据。成功加载数据后,我需要做一些额外的工作。如果我使用 subscribe 功能,我可以很容易地在 subscribe 中做到这一点,例如:

http.get("/addressOfService").subscribe(data=>{
   this.info =data;
   DoJob();
});
Run Code Online (Sandbox Code Playgroud)

但我知道加载数据并在视图中使用它的最佳实践是尽可能长时间地使用异步管道,所以我正在使用它。现在我的问题是在加载数据并且用户使用异步管道时运行函数的最佳实践是什么。我尝试了一些不同的解决方案,发现我可以使用 map 函数,例如:

http.get("/addressOfService").pipe(map(data=>{
   DoJob();
   return data;
}));
Run Code Online (Sandbox Code Playgroud)

但我不确定这是否是一个好习惯。

observable rxjs angular angular6

0
推荐指数
1
解决办法
52
查看次数

如何在角度 6 中使用 *ngFor 绑定对象数组

{
    "Search": [
        {
            "name": "akram",
            "roll": 101
        },
        {
            "name": "wasim",
            "roll": 102
        }
    ],
    "total": "two record"
}
Run Code Online (Sandbox Code Playgroud)

我想这样打印:

akram 101
wasim 102
Run Code Online (Sandbox Code Playgroud)

angular angular6

0
推荐指数
1
解决办法
79
查看次数