我最近将我的应用程序迁移到Angular 6,它在角度5中运行良好,我遇到了很多问题,但无论如何我解决了它们,但PWA我无法迁移,在角度5 PWA工作正常,但在6给出以下错误......
当我跑步的时候
command ng add @angular/PWA its showing error
**Error **
target is not defined for the specified project
Run Code Online (Sandbox Code Playgroud)
请帮助如何在Angular 6中迁移或添加PWA
我遇到的问题是Angular 6中的html元素(下面示例中的按钮)似乎缺少默认边距:
Angular 5.2.2示例 - 按钮之间具有默认边距/间距
Angular 6.0示例 - 缺少按钮之间的边距/间距
我希望有人可以确认这是一个有角度的问题 - 或者指出问题的根源 - 在我打开一个github问题之前
太棒了,Angular发布了版本6,CLI提供了生成库的选项-他们称其为“备受期待的功能”。
现在,从业务角度来看,我想知道:
所以我明白了,在npmjs上发布了一些东西,希望整个世界以及未来的连接事物都需要它。图书馆,太好了。
在更大的公司的大型系统中,我们可以重用库,但是我们已经能够使用模块重用东西。我需要分别构建库并在每次更改内容时重新编译。
使用库而不是模块的原因是什么?
(现在我想说,一个lib可以比模块更大,所以我只是用它来组织我的应用程序更好)
Angular材质的扩展面板取决于BrowserAnimationsModule.我已经包含了动画模块,但是当我创建一个简单的扩展面板时,它崩溃并出现错误:
错误TypeError:this.driver.containsElement不是TransitionAnimationEngine.push ../ node_modules上TransitionAnimationEngine.push ../ node_modules/@angular/animations/fesm5/browser.js.TransitionAnimationEngine._balanceNamespaceList( browser.js:2765)的函数.在TransitionAnimationEngine.push ../node_modules/@angular/animations/fesm5/browser.js.TransitionAnimationEngine.register(browser.js:/@angular/animations/fesm5/browser.js.TransitionAnimationEngine.createNamespace( browser.js:2743) 2784)在InjectableAnimationEngine.push ../ node_modules/@angular/animations/fesm5/browser.js.AnimationEngine.register(browser.js:3815),在AnimationRendererFactory.push ../ node_modules/@ angular/platform-browser/fesm5/createComponentView(core.js)上的DebugRendererFactory2.push ../ node_modules/@angular/core/fesm5/core.js.DebugRendererFactory2.createRenderer(core.js:12225)的animations.js.AnimationRendererFactory.createRenderer(animations.js:140) :11179)在Object.de的callWithDebugContext(core.js:12204)createViewNodes上的bugCreateComponentView [as createComponentView](core.js:11715)(core.js:11220)
home.component.html
<div class="container-fluid">
<div id="sidebar">
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
This is the expansion title
</mat-panel-title>
<mat-panel-description>
This is a summary of the content
</mat-panel-description>
</mat-expansion-panel-header>
<p>This is the primary content of the panel.</p>
</mat-expansion-panel>
</div>
<div id="map" style="height: 550px"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
home.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
import { …Run Code Online (Sandbox Code Playgroud) angular-ui angular-material angular angular-animations angular6
(我在这里转载我的问题:https : //plnkr.co/QvEWjhJhbsghy1OD)
<ng-select>选项的下拉列表未显示在该<ngx-datatable>行的上方,似乎已被单元格的高度削减,使其变得毫无用处。
常规<select>效果很好,但我可以看到所有选项。
如何使ng-select正常工作?
我有以下具有数据源属性的角度材质表:
<div class="dim">
<mat-form-field >
<input matInput class="warn" (keyup)="applyFilter($event.target.value)" placeholder="Search">
<mat-icon matSuffix>search</mat-icon>
</mat-form-field>
</div>
<div class="mat-elevation-z2">
<table mat-table [dataSource]="dataSource" matSort>
<ng-container matColumnDef="unit_id">
<th mat-header-cell *matHeaderCellDef mat-sort-header>ID</th>
<td class="alignTd" mat-header *matCellDef="let row">{{row.id}}</td>
</ng-container>
<ng-container matColumnDef="unit_type">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Type</th>
<td mat-header *matCellDef="let row">{{row.unit_type}}</td>
</ng-container>
<ng-container matColumnDef="location_id_auto">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Location</th>
<td mat-header *matCellDef="let row">{{row.location}}</td>
</ng-container>
<ng-container matColumnDef="user_id">
<th mat-header-cell *matHeaderCellDef mat-sort-header>User</th>
<td mat-header *matCellDef="let row">{{row.user}}</td>
</ng-container>
<ng-container matColumnDef="unit_number_hh">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Number Of units</th>
<td mat-header *matCellDef="let row">{{row.unit_number}}</td>
</ng-container>
<ng-container matColumnDef="unit_status"> …Run Code Online (Sandbox Code Playgroud) 使用Angular 6,我在使用材料力矩适配器时遇到了麻烦。在我的moment-date-adapter.d.ts文件中,当尝试从中导入{Moment}时,在导入语句中显示“找不到'module'”
node_modules/@angular/material-moment-adapter/typings/adapter/moment-date-adapter.d.ts。
我的tsconfig.json如下:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
Run Code Online (Sandbox Code Playgroud)
我的进口声明很简单
import { Moment } from 'moment';
Run Code Online (Sandbox Code Playgroud)
从我的moment-date-adapter.d.ts文件中。
任何帮助,将不胜感激。
如何在Angular6中绑定输入文本以跨越innerHTML?
ts文件
...
finance_fullname: string;
...
Run Code Online (Sandbox Code Playgroud)
模板文件
<input type="text" id="finance_fullname" [(ngModel)]="finance_fullname">
<span class="fullname" ngBind="finance_fullname"></span>
Run Code Online (Sandbox Code Playgroud) 问题是:我需要进行http调用并存储生成动态路由所需的对象。因此,我正在利用APP_INITIALIZER。
// app.module.ts
import { ApplicationService } from './application.service';
providers: [
ApplicationService,
{
provide: APP_INITIALIZER, useFactory: appServiceFactory, deps:
[Injector, ApplicationService], multi: true
},
],
function appServiceFactory(injector: Injector, appService: ApplicationService): Function {
return () => {
return appService.loadApplication().then((app: Application) => {
/custom logic
});
});
};
}
// application.service.ts
@Injectable({
providedIn: 'root'
})
// navigation.component.ts
import { ApplicationService } from './application.service';
export class NavigationComponent implements OnInit {
constructor(private _applicationService: ApplicationService) {
}
Run Code Online (Sandbox Code Playgroud)
}
但是在navigation.component内部,再次初始化applicationservice。我敢肯定,因为如果我记录或放置调试器语句,则该服务的Construct()方法将被调用两次。
为什么即使将Service声明为Singleton并providedIn: root重新实例化?
在我的angular 6项目中,我有一个动态创建的组件,如下所示:
@Component({
selector: 'app-staff-dash',
template: `
<template #tasksContainer></template>
`
})
export class StaffDashComponent implements OnInit {
componentRef: any;
factory: any;
@ViewChild('tasksContainer', { read: ViewContainerRef }) tasksEntry: ViewContainerRef;
constructor(
@Inject(ComponentFactoryResolver) private resolver: ComponentFactoryResolver
) {
}
ngOnInit() {
this.createTasksComponent();
}
createTasksComponent(): void {
this.tasksEntry.clear();
this.factory = this.resolver.resolveComponentFactory(TasksComponent);
this.componentRef = this.tasksEntry.createComponent(this.factory);
}
}
Run Code Online (Sandbox Code Playgroud)
StaffDashComponent是父母,TasksComponent是孩子。现在,我希望将一些数据从传递TasksComponent到StaffDashComponentusing @Output。我该如何实现?
angular6 ×10
angular ×8
angular5 ×2
angular-cli ×1
angular-ui ×1
css ×1
data-binding ×1
datasource ×1
html ×1
pagination ×1
singleton ×1