标签: angular6

Asp.net核心2采用角度6模板

我正在寻找一个模板,使用带有角度6的asp.net core 2.0在一个解决方案中使用f5命中来运行应用程序.

你能帮忙找到这样的要求吗?

谢谢

asp.net angular6

5
推荐指数
1
解决办法
4474
查看次数

Angular 6自定义库没有ComponentFactoryResolver的提供程序

我从NG4-> NG6重写库(使用angular-cli 6)。这个lib改变了dynamicli的角度分量,所以我使用了ComponentFactoryResolver,在这里我卡住了。当我添加ComponentFactoryResolver到构造函数中时:

constructor(
    private componentFactoryResolver: ComponentFactoryResolver
) {}
Run Code Online (Sandbox Code Playgroud)

并在目标应用程序中构建lib(成功)(我从本地文件中将我的lib添加到package.json中)我遇到此错误:

StaticInjectorError(AppModule)[MyLibComponent-> ComponentFactoryResolver]: 
  StaticInjectorError(Platform: core)[MyLibComponent-> ComponentFactoryResolver]: 
    NullInjectorError: No provider for ComponentFactoryResolver!
    at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:979)
    at resolveToken (core.js:1232)
    at tryResolveToken (core.js:1182)
    at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1077)
    at resolveToken (core.js:1232)
    at tryResolveToken (core.js:1182)
    at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1077)
    at resolveNgModuleDep (core.js:9238)
    at NgModuleRef_.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (core.js:9919)
Run Code Online (Sandbox Code Playgroud)

没有ComponentFactoryResolver其他事情就可以正常工作

完整组成部分:

import { Component, ComponentFactoryResolver, AfterContentInit, ViewChild, Inject, Input, InjectionToken } from '@angular/core';

import { AbHostDirective } from './../directives/ab-host.directive';

export const AB_COMPONENTS = new InjectionToken('AB_COMPONENTS');

@Component({ …
Run Code Online (Sandbox Code Playgroud)

components dynamic angular-cli angular angular6

5
推荐指数
1
解决办法
2452
查看次数

Angular Material v6 Mat-Footer - "无法读取未定义的属性'模板'"

为了这个目的,我最近在升级到角度6之后尝试在mat-table组件中实现一个页脚行,但是在表格中添加mat-footer-cell和mat-footer-row元素后,我得到以下内容错误:

错误类型错误:无法在MatFooterRowDef.push读取未定义的属性"模板"../ node_modules/@angular/cdk/esm5/table.es5.js.CdkFooterRowDef.extractCellTemplate(vendor.js:17400)

该表仍显示在页面上,但没有数据,没有页脚行,并且每个列标题右侧的T符号.

HTML:

  <ng-container matColumnDef="total">

    <mat-header-cell *matHeaderCellDef mat-sort-header style="width: 15%; flex: none">Total</mat-header-cell>

    <mat-cell *matCellDef="let item" style="width: 15%; flex: none">{{item.total | currency: 'GBP'}}</mat-cell>

    <td mat-footer-cell *matFooterCellDef>100</td>

  </ng-container>

  <mat-header-row *matHeaderRowDef="tableColumns"></mat-header-row>

  <mat-row *matRowDef="let row; columns: tableColumns" (click)="editItem(row)"></mat-row>

  <tr mat-footer-row *matFooterRowDef="tableColumns"></tr>

</mat-table>
Run Code Online (Sandbox Code Playgroud)

angular-material angular angular6

5
推荐指数
3
解决办法
8858
查看次数

使用多种配置构建应用

是否可以将常见样式与配置特定样式结合在一起?还是要具体说明一下,使用多种配置构建应用?


我有一个应用程序,它根据构建期间使用的配置使用不同的材质主题。这是build应用程序部分的angular.json外观:

"build": {
  "builder": "@angular-devkit/build-angular:browser",
    "options": {
        "outputPath": "dist/my-app",
        "index": "src/index.html",
        "main": "src/main.ts",
        "tsConfig": "src/tsconfig.app.json",
        "scripts": [ ],
        "styles": [
          // These are the common styles
          "src/styles.scss"
        ],
        "assets": [
          "src/assets",
          "src/favicon.ico"
        ]
      },
      "configurations": {
        "theme-one": {
          "styles": [                
            "src/styles/themes/material.theme-one.scss"
          ]
        },
        "theme-two": {
          "styles": [                
            "src/styles/themes/material.theme-two.scss"
          ]
        }
      }
    },
Run Code Online (Sandbox Code Playgroud)

?预期行为:

我想添加/合并styles各个配置中styles指定的以及中的指定build:options。例如,使用以下命令:

ng build --configuration theme-one
Run Code Online (Sandbox Code Playgroud)

上面的命令应包含"src/styles.scss"和"src/styles/themes/material.theme-one.scss"。相同theme-two。

?当前行为:

当前行为是,当我指定配置时,该配置中的 …

angular-cli angular angular6 angular-cli-v6

5
推荐指数
1
解决办法
700
查看次数

在Angular2中移动HTML滑块时动态更新变量的值

我在我的angular6应用程序中使用html圆形滑块:https ://www.w3schools.com/howto/howto_js_rangeslider.asp

.html文件中的实现如下所示:

<span style="font-size: 130px;">{{sliderVal}}</span>

<input type="range" #slider min="1" max="10" value="1" class="slider" (change)="onPriceSliderChange(slider.value)">
Run Code Online (Sandbox Code Playgroud)

.ts文件的实现:

import { Component } from '@angular/core';

@Component({
  selector: 'app-sample,
  templateUrl: './sample.component.html',
  styleUrls: ['./sample.component.scss']
})
export class SampleComponent {
  public sliderVal = 1;
  constructor() { }

  onPriceSliderChange(val) {
    this.sliderVal = val;
  }

}
Run Code Online (Sandbox Code Playgroud)

仅当移动滑块并且我不按下鼠标左键时,sliderVal值才会更改。我想每次移动滑块时都动态地更新sliderVal的值,而不仅是在取消按下鼠标按钮时。我知道如何使用jQuery实现此目的,但我不想将jQuery解决方案与Angular混合使用。有任何想法吗?干杯

ecmascript-6 angular angular6

5
推荐指数
1
解决办法
1403
查看次数

以角度6动态添加div容器

如何以角度动态添加div容器?

请看我的HTML代码.每当我点击"添加"按钮时,一个新的div应该添加该按钮的左侧.动态地,它应该根据点击的方式添加多个容器.一切都应该横向加入.如果默认情况下它是更多的容器,它应该添加滚动并且它是统一的.任何人都可以帮我做到这一点angular 6.

#content{
    width:100%;
    height:90px;
    border:1px solid black;
}
#contentInside{
    width:100px;
    height:70px;
    margin:7px;
    border:1px solid black;
    display:inline-flex;
}
Run Code Online (Sandbox Code Playgroud)
<div id="content">
    <div id="contentInside">
    
    </div>
    <button (click)="add()">Add</button> 

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

我是棱角分明的新人.请有人帮我这样做.

html css angular angular6

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

Angular 6:功能模块之间的共享组件不起作用

我创建了2个功能模块(PagesSharedModule&HomeModule).
现在,我正在尝试使用组件PagesSharedModule模板内部的导出组件,HomeModule我收到此错误:

ERROR Error: Uncaught (in promise): Error: Template parse errors: 'app-main-menu' is not a known element:
1. If 'app-main-menu' is an Angular component, then verify that it is part of this module.
2. If 'app-main-menu' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("[ERROR
->]<app-main-menu></app-main-menu>"): ng:///HomeModule/HomeComponent.html@0:0 Error: Template parse errors: 'app-main-menu' is not a known element:
1. If 'app-main-menu' is an Angular …
Run Code Online (Sandbox Code Playgroud)

typescript angular-module angular-components angular angular6

5
推荐指数
1
解决办法
4340
查看次数

如何在FormArray(反应性表单)中使用mat-autocomplete(角材料自动完成)

假设我具有以下表单结构:

  this.myForm = this.formBuilder.group({
          date: ['', [Validators.required]],
          notes: [''],
          items: this.initItems()

        });
  initItems() {
    var formArray = this.formBuilder.array([]);
    for (let i = 0; i < 2; i++) {
      formArray.push(this.formBuilder.group({
        name: ['', [Validators.required]],
        age: ['', [Validators.required]],
      }));
    }

    return formArray;
  }
Run Code Online (Sandbox Code Playgroud)

并且名称控件应该是自动完成的,如何将所有名称控件与自动完成列表相关联?

angular-material angular angular6

5
推荐指数
1
解决办法
2435
查看次数

“ Angular 6 ng build --prod错误”错误错误:ngIfElse必须是TemplateRef,但是收到了'true'。

错误错误:ngIfElse必须是TemplateRef,但是收到'true'

HTML文件

<select class="form-control">
  <option selected value="0">Select Manufacturer</option>
  <option *ngFor="let brand of allMakes">
     {{ brand.brand }}
  </option>
</select>
Run Code Online (Sandbox Code Playgroud)

ts文件

  this.allMakes = [{
    id: '1',
    brand: 'Mazda'
  },
  {
    id: '2',
    brand: 'Audi',
  }];
Run Code Online (Sandbox Code Playgroud)

我从Angular 5升级到Angular 6之后,一切就开始了

控制台日志错误

ERROR Error: ngIfElse must be a TemplateRef, but received 'true'.
  at Vt (main.6e360f04b7d39ee1dc33.bundle.js:1)
  at t.set [as ngIfElse] (main.6e360f04b7d39ee1dc33.bundle.js:1)
  at Sa (main.6e360f04b7d39ee1dc33.bundle.js:1)
  at main.6e360f04b7d39ee1dc33.bundle.js:1
  at main.6e360f04b7d39ee1dc33.bundle.js:1
  at es (main.6e360f04b7d39ee1dc33.bundle.js:1)
  at Os (main.6e360f04b7d39ee1dc33.bundle.js:1)
  at Object.updateDirectives 
  (main.6e360f04b7d39ee1dc33.bundle.js:1)
  at Object.updateDirectives (main.6e360f04b7d39ee1dc33.bundle.js:1)
  at ts (main.6e360f04b7d39ee1dc33.bundle.js:1)
Run Code Online (Sandbox Code Playgroud)

javascript typescript angular6

5
推荐指数
2
解决办法
5567
查看次数

垫选择显示的值不同于垫选择的值

我有一个mat-select下拉列表,在这里我遍历了frequencyArr对象。

在ts

frequencyArr = [
{key : "Once daily", abbriviation : '0-0-1'},
{key : "Twice daily", abbriviation : '1-0-1'},
{key : "Thrice daily", abbriviation : '1-1-1'},
{key : "Four times a day", abbriviation : '1-1-1-1'}
  ]
Run Code Online (Sandbox Code Playgroud)

在html中

<mat-select placeholder="frequency" formControlName="frequency" required>                             
    <mat-option *ngFor="let frequency of frequencyArr" [value]="frequency.abbriviation">
        <span>{{frequency.key }} : {{ frequency.abbriviation}}</span>
    </mat-option>
</mat-select>
Run Code Online (Sandbox Code Playgroud)

我想做的是打开对话框时将显示对象键:object value-

<span>{{frequency.key }} : {{ frequency.abbriviation}}</span>
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

很好,但是当我选择该选项时,它应该仅将frequency.key显示到所选字段中,而不会发生。

在此处输入图片说明

我尝试使用Google谷歌搜索,但在这种情况下没有找到任何东西。任何帮助表示赞赏。

angular-material angular6

5
推荐指数
2
解决办法
1633
查看次数