您好我试图在我的Web应用程序中实现firestore,当我向构造函数添加服务时出现错误:
NullInjectorError:没有TesteventService的提供者!
我正在使用Angular 5,angularfire2/firestore和typescript 2.7.1
testevent.service.ts
import { Injectable } from '@angular/core';
import { AngularFirestore } from 'angularfire2/firestore'
@Injectable()
export class TesteventService {
constructor(private afs: AngularFirestore) { }
addEvent(eventData){
this.afs.collection('testevent').add(eventData).then(() => {
console.log('Done');
})
}
getEvent(){
return this.afs.collection('testevent', ref => ref.orderBy('id')).valueChanges()
}
}
Run Code Online (Sandbox Code Playgroud)
component.ts
import { Component, OnInit } from '@angular/core';
import { TesteventService } from '../../providers/testevent.service';
import { AngularFirestore } from 'angularfire2/firestore';
export class CsvImportComponent implements OnInit {
data_rows = []
constructor(private event: TesteventService){})
Run Code Online (Sandbox Code Playgroud)
当我从TesteventSerivice添加事件时,我得到错误,而没有任何运行.
我正在尝试在我的角度npm包中创建我认为称为辅助入口点的东西。我想要以下两个切入点
@scope/data-service
@scope/data-service/models
Run Code Online (Sandbox Code Playgroud)
使用angular-cli生成基本包会生成以下结构
scope
????data-service
? karma.conf.js
? ng-package.json
? ng-package.prod.json
? package.json
? tsconfig.lib.json
? tsconfig.spec.json
? tslint.json
?
????src
? public_api.ts
? test.ts
?
????lib
data-service.component.spec.ts
data-service.component.ts
data-service.module.ts
data-service.service.spec.ts
data-service.service.ts
Run Code Online (Sandbox Code Playgroud)
根据ng-packagr 文档,您可以在名为datas的数据服务下添加一个文件夹,然后package.json在该文件夹中添加第二个文件夹,但是ng-packagr似乎使用的结构与angular-cli略有不同。理想情况下,我正在尝试对类似于https://github.com/angular/angular/tree/master/packages/common的结构进行建模,但只要公开了@scope/data-service,@scope/data-service/models我就会很高兴。
当我尝试创建类似于ng-packager建议的结构时,我得到了
error TS6059: File 'C:/projects/data-service-app/projects/scope/data-service/models/src/index.ts' is not under 'rootDir' 'C:\projects\data-service-app\projects\scope\data-service\src'. 'rootDir' is expected to contain all source files.
当我将models目录移动到data-service\src目录中时,我的入口点是
@scope/data-service
@scope/data-service/src/models
Run Code Online (Sandbox Code Playgroud)
如何摆脱二级入口上的src?
使用angular-cli时,使用辅助入口点创建库的正确方法是什么?
我想在Angular中计算下载和上传网速.
对API的请求不是最佳解决方案,因为如果服务器本身从加载速度变慢,结果将是不正确的.
也许Angular有解决方案,它使用特殊网站(例如speedtest.net).
有任何想法吗?
我会使用Typedjs以角度2制作打字机效果
如网站所示,我已经用npm安装了包:
npm install typed.js
Run Code Online (Sandbox Code Playgroud)
然后我将此代码添加到我的组件:
import Typed from 'typed.js';// not sure if it's the right way
Run Code Online (Sandbox Code Playgroud)
和
ngOnInit() {
var typed = new Typed(".element", {
strings: ["This is a JavaScript library", "This is an ES6 module"],
smartBackspace: true // Default value
});
}
Run Code Online (Sandbox Code Playgroud)
然后在我的html文件中:
<div id="typed-strings">
<p>Typed.js is an <strong>Awesome</strong> library.</p>
<p>It <em>types</em> out sentences.</p>
</div>
<span id="typed"></span>
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
/home/haddad/projects/siteperso/src/app/slide-presentation/slide-presentation.component.ts (18,21): Cannot find name 'Typed'.
PS:我对任何其他与Typed.js做同样工作并与Angular 2/4合作的提议持开放态度
我正在使用mat-calendar。我正在尝试突出显示某些日期,但我做不到。没有适当的文档。
的HTML
<mat-card>
<mat-calendar name="appointment_date" [selected]="selectedDate (selectedChange)="onSelect($event)"></mat-calendar>
</mat-card>
Run Code Online (Sandbox Code Playgroud)
TS
onSelect(event){
this.selectedDate= event;
}
Run Code Online (Sandbox Code Playgroud)
我需要的:
谁能帮我一个忙。
我已在此处输入链接说明中上传了整个项目
每次我运行相同的代码并得到以下错误后,都会收到很多错误提示:
`node_modules/@ngrx/store-devtools/src/actions.d.ts(18,21)中的错误:错误TS1039:在环境中不允许初始化。
node_modules/@ngrx/store-devtools/src/actions.d.ts(22,21):错误TS1039:在环境上下文中不允许初始化。
node_modules/@ngrx/store-devtools/src/actions.d.ts(26,21):错误TS1039:在环境上下文中不允许初始化。
node_modules/@ngrx/store-devtools/src/actions.d.ts(31,21):错误TS1039:在环境上下文中不允许初始化。
node_modules/@ngrx/store-devtools/src/actions.d.ts(36,21):错误TS1039:在环境上下文中不允许初始化。
node_modules/@ngrx/store-devtools/src/actions.d.ts(40,21):错误TS1039:在环境上下文中不允许初始化。
node_modules/@ngrx/store-devtools/src/actions.d.ts(44,21):错误TS1039:在环境上下文中不允许初始化。
node_modules/@ngrx/store-devtools/src/actions.d.ts(51,21):错误TS1039:不允许初始化程序node_modules/@ngrx/store-devtools/src/actions.d.ts(56,21) :错误TS1039:不允许初始化
node_modules/@ngrx/store-devtools/src/actions.d.ts(61,21):错误TS1039:不允许初始化
node_modules/@ngrx/store-devtools/src/actions.d.ts(66,21):错误TS1039:不允许初始化
node_modules/@ngrx/store-devtools/src/actions.d.ts(71,21):错误TS1039:不允许初始化
node_modules/@ngrx/store-devtools/src/actions.d.ts(76,21):错误TS1039:不允许初始化
我?wdm ?:编译失败。`
有机会在不更改代码的情况下成功完成项目编译,但是又有另一个错误 Uncaught Error: Can't resolve all parameters for CoinEffects: (?, [object Object]).
经过多次搜索后,我发现它是关于循环依赖关系的,它试图解决,但是徒然是关于依赖关系或其他问题!!?
angular ×6
typescript ×3
angular-cli ×1
angular5 ×1
c# ×1
javascript ×1
ng-packagr ×1
ngrx ×1
typedjs ×1