我看了一下新ng generate @angular/material:material-nav在这近角博客功能项.
不幸的是,当在一个全新的项目中运行以下CLI命令时,我收到一条错误消息(见下文).
ng add @angular/material
ng generate @angular/material:material-nav
Run Code Online (Sandbox Code Playgroud)
错误信息:
Schematic input does not validate against the Schema: {"dryRun":false,"inlineStyle":false,"inlineTemplate":false,"changeDetection":"Default","styleext":"css","spec":true,"flat":false,"skipImport":false,"export":false}
Errors:
Data path "" should have required property 'name'.
Run Code Online (Sandbox Code Playgroud)
这种糟透了.我尝试添加这样的名字
ng generate @angular/material:material-nav home
Run Code Online (Sandbox Code Playgroud)
但它仍然会产生相同的错误.请指教.
Angular CLI:6.0.0节点:8.11.1 OS:darwin x64 Angular:6.0.0
我正在尝试对有棱角的材料进行排序MatTable,MatSort但问题是我只能对我的两列进行排序,MatTable但我想要的是对所有列进行排序,但我不明白为什么它不起作用......我可以单击箭头,就像我想对表的数据进行排序时一样,但除了列multiple和occupation排序良好之外什么也没有发生。
这是我的代码(我很好地导入MatSortModule到我的app.module.ts):
import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core';
import {PosteCSRPoste, PosteCSRService} from '../../api';
import {MatSort, MatTableDataSource} from '@angular/material';
@Component({
selector: 'app-csr',
templateUrl: './csr.component.html',
styleUrls: [
'./csr.component.css',
'../app.component.css'
]
})
export class CsrComponent implements OnInit, AfterViewInit {
displayedColumns = [
'disciplineCsd',
'disciplineCsr',
'multiple',
'communeIdentique',
'etablissementCsd',
'etablissementCsr',
'occupation'
];
postes = new MatTableDataSource<PosteCSRPoste>();
@ViewChild(MatSort) sort: MatSort;
constructor(private posteCSRService: PosteCSRService) {
}
ngOnInit(): void {
this.getPostesCSR();
} …Run Code Online (Sandbox Code Playgroud) 我有一个场景,我想通过进行 Http REST 调用来获取匹配的字符串,将每次击键时输入框中存在的字符串发送到服务器。但它并没有像我预期的那样工作,例如假设输入框中的当前值是“模块”,如果我在“模块”之后输入字符“e”,我希望传递给searchDepartmentsWithName
方法的值将是“模块” ' 但它给出了当前值 'modul' 而不是修改后的值 'module',后者发送到服务器并返回错误的匹配字符串。简而言之,传递给searchDepartmentsWithName方法的值始终是修改前的值。我们如何解决这个问题,或者这是否是正确的做法?
searchnox.component.html
<body>
<input type="text" placeholder="enter department name here.." (keypress)="searchDepartmentsWithName($event.target.value)" class="ticketinginput" />
<div *ngFor="let department of searchResults; let i = index">
<p id="result" href="#" (click)="onClick(department)">{{ department.departmentName }}</p>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
searchbox.component.ts
searchDepartmentsWithName(departmentName: string) {
this.serverService.searchDepartment(departmentName).subscribe( (response) => {
console.log(response);
},
(error) => console.log(error)
);
this.prepareSearchResults();
}
Run Code Online (Sandbox Code Playgroud)
server.service.ts
searchDepartment(name: string) {
this.departmentList = new Array();
const url = `http://localhost:8082/request/searchDepartmentsByName/${name}`;
return this.http.get(url).map(
(response: Response) => {
const data = response.json();
for …Run Code Online (Sandbox Code Playgroud) Angular 6 App 在 ng build 上运行良好。
但是在 ng build --prod 应用程序 UI 被加载但在登录时,我将从服务器获取 coorect 数据,之后我通过代码导航到仪表板页面this.router.navigate(['/dashboard']);,出现如下错误
错误错误:未捕获(承诺):错误:StaticInjectorError(a)[t]:StaticInjectorError(Platform:core)[t]:NullInjectorError:t 没有提供者!错误:StaticInjectorError(a)[t]: StaticInjectorError(Platform: core)[t]: NullInjectorError: 没有提供者为 t!在 t.get (main.aa8ef128615c160bd861.js:1) 在 main.aa8ef128615c160bd861.js:1 在 t (main.aa8ef128615c160bd861.js:1) 在 t.8ef5161bd861861.js:1 att.8ef58c6161616161616161000000js:1616ajs861.js:1 js:1 at t (main.aa8ef128615c160bd861.js:1) at t.get (main.aa8ef128615c160bd861.js:1) at Da (main.aa8ef128615c160bd861.js.get8ef16t10js:1(main.aa8ef128615c160bd861.js:1) at ) 在 t.getToken (main.aa8ef128615c160bd861.js:1) 在 t.get (main.aa8ef128615c160bd861.js:1) 在 main.aa8ef128615c160bd861.js:1 在 t.get (main.aa8ef128615c160bd861.js:1) at main.aa8ef128615c160bd861.js:1 在 (main.aa8ef128615c160bd861.js:1) at main.aa8ef128615c160bd861.js:1 在 (main.aa8ef128615c160bd861.js:1) at861d861.js:1 att.8a1d61d61d6.js:1 (main.aa8ef128615c160bd861.js:1) at main.aa8ef128615c160bd861.js:1 at t (main.aa8ef128615c160bd861.js:1)
我的 App.module.ts 看起来像,
import { BrowserModule …Run Code Online (Sandbox Code Playgroud) 在早期版本中,我能够将组件选择器指定为属性.
@Component({
selector: '[app-row]',
...
})
export class RowComponent implements OnInit {
ngOnInit() {}
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<tr app-row></tr>
Run Code Online (Sandbox Code Playgroud)
现在我得到了lint错误:
错误:/ path/to/row.component.ts [8,13]:组件"RowComponent"的选择器应该用作元素(https://angular.io/styleguide#style-05-03)
我意识到我可以在元素中嵌入一个tr,但我并不总是能控制样式,我个人不喜欢不必要的嵌套,一般都试图避免它.
如果我应该总是使用元素选择器,如何将组件指定为"tr"元素.IE: <app-row></app-row>?什么是适当的Angular 6方法来实现这一目标?
注意:我已经查看了样式指南的链接,该部分没有涵盖与我的特定用例类似的内容.我也尝试通过id选择,但得到相同的lint错误.
我正在使用angular/cli": "~6.1.5 和rxjs": "^6.0.0
作为Angular 6的新手,我开始从官方文档中学习
http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html
代码如下
var clicks = Rx.Observable.fromEvent(document, 'click');
var result = clicks.throttleTime(1000);
result.subscribe(x => console.log(x));
Run Code Online (Sandbox Code Playgroud)
我在角度6中尝试过相同的代码
fromEvent(mybuttonId, 'click')
.subscribe((event) => console.log('clicked'));
Run Code Online (Sandbox Code Playgroud)
但是,如果我从事件添加.throttleTime(1000),那么它将抛出错误
属性'throttleTime'在类型'Observable上不存在
"`.
如果我尝试添加Observable.fromEvent,那么该方法不存在
我已经导入了Rx js
import {Observable, fromEvent, from, of} from 'rxjs';
import {throttleTime} from 'rxjs/operators';
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助我找到最新版本的确切文档.
谢谢
我需要从单选按钮中获取价值。假设具有以下html代码:
<label class="radio-inline">
<input class="form-check-input" type="radio" [(ngModel)]="dog" name="gob" value="i" [checked]="true" (change)="onItemChange(item)"/>Dog
</label>
<label class="radio-inline">
<input class="form-check-input" type="radio" [(ngModel)]="cat" name="cat" value="p" (change)="onItemChange(item)"/>Cat
</label>
Run Code Online (Sandbox Code Playgroud)
在我的ts页面中,我需要获取单选按钮的值,例如
dog.value
Run Code Online (Sandbox Code Playgroud)
我的目的是:
有人可以帮助我吗?
我有一个mat-menu包含多个复选框的应用程序,我希望用户在检查所需的所有类型的过滤器时将其关闭。
实际的行为是当您单击任何内容时,它将自动关闭。
我有以下代码:
<button color="warn" mat-button [matMenuTriggerFor]="menu">Menu</button>
<mat-menu #menu="matMenu">
<button mat-menu-item>
<mat-checkbox color="warn">
By LM
</mat-checkbox>
</button>
<button mat-menu-item>
<mat-checkbox color="warn">
By UN
</mat-checkbox>
</button>
</mat-menu>
Run Code Online (Sandbox Code Playgroud)
他们从文档中说:
@Output()关闭:EventEmitter
菜单关闭时发出的事件。
但是我无法弄清楚如何使用此输出,以及它是否与我需要的输出有关。
这是一堆堆炸弹。
如何防止mat-menu在用户未单击的情况下关闭?
angular angular6 angular-material-5 angular-material-6 angular7
我已经通过angularx-social-login集成了社交登录名(Google和Facebook),现在找到了一种集成基于Microsoft帐户的方法。
有没有办法将Microsoft帐户(hotmail,live,outlook)与Angular集成?
网络中的所有搜索和示例大部分都特定于Microsoft Azure。是否有任何npm库可以集成此库?有任何想法吗?
我是Angular的新手,正在寻找席卡上的分页。我看到的示例仅对表进行分页。
我有数百个代码,希望将其限制为每页8-10张卡片。如何做到这一点?这是我的html和ts代码。
.html文件
<div class="flip-right" [ngClass]="mobileQuery.matches ? 'card-wrapper-mobile' : 'card-wrapper'" *ngFor="let items of datasource">
<div class="card">
<div class="front">
<mat-card [ngClass]="mobileQuery.matches ? 'mobile-card' : 'desktop-card'">
<a routerLink="/viewPage">
<mat-card-header class="header">
<mat-card-title>{{items.name}} <mat-icon class="verified title" [inline]="true" >lock</mat-icon></mat-card-title>
</mat-card-header>
<mat-card-subtitle class="first-subtitle">Last updated on:{{items.Last_updated_on}}</mat-card-subtitle>
<mat-card-subtitle>Last updated by:{{items.Last_updated_by}}</mat-card-subtitle>
<mat-card-subtitle>{{items.created_by}}</mat-card-subtitle>
</a>
</mat-card>
</div>
<div class="back">
<mat-card [ngClass]="mobileQuery.matches ? 'mobile-card' : 'desktop-card'">
<a routerLink="/viewPage">
<mat-card-header>
<mat-card-title>{{items.name}}<mat-icon class="verified" [inline]="true" >lock</mat-icon></mat-card-title>
</mat-card-header>
</a>
</mat-card>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
.ts文件
import { Component, OnInit,ViewChild } from '@angular/core';
import { Subscription } from …Run Code Online (Sandbox Code Playgroud) angular6 ×10
angular ×8
angular7 ×3
angular-cli ×1
html-table ×1
javascript ×1
keypress ×1
pagination ×1
rxjs ×1
sorting ×1
tslint ×1