angular6

Typescript Error: TS2314: Generic type 'ElementRef<T, any>' requires 2 type argument(s)

a 夏天 提交于 2019-12-10 06:15:21
问题 I'm using an Angular 5.x template, but I upgrade it to Angular 6 using https://update.angular.io/ guide. Now I have this error in my constructor Typescript Error: TS2314: Generic type 'ElementRef<T, any>' requires 2 type argument(s) My Code: import { Component, Input, Output, EventEmitter, ElementRef, HostListener } from '@angular/core'; @Component({ selector: 'sidebar', templateUrl: './sidebar.component.html' }) export class SidebarComponent { @HostListener('document:click', ['$event'])

Two way binding on angular 6 reactive form

梦想与她 提交于 2019-12-10 02:58:26
问题 I am trying to create a complex reactive form with nested component that is populated with a data object. The behavior I am trying to achieve is very similar to the two-way data binding of a template-driven form: when the user edits an input of the form, the data object is changing automatically . but as opposed to template-driven form, I cannot use [(ngModel)] because it is deprecated in reactive forms for angular V6. I know that fromGroup.patchValue() will only do a one way binding and then

Angular 6 service with interface

試著忘記壹切 提交于 2019-12-10 02:54:27
问题 I am building an application with Angular ( 6.0.7 ) and I am trying to create a service with the new: @Injectable({ providedIn: 'root' }) But how can I type an injection with an Interface? The problem I have 2 services, Authentication.service and SessionStorage.service . I want to inject the sessionstorage into the authentication service. That can be done via: constructor(private sessionStorage: SessionStorage) { } No problem there. But for Object Orientated purposes I want to have an

@angular/platform-browser/platform-browser"' has no exported member 'HammerLoader'

你。 提交于 2019-12-10 02:04:06
问题 I tried to run "ng build", I'm getting following error. "ERROR in node_modules/@angular/material/core/typings/common-behaviors/common-module.d.ts(9,10): error TS2305: Module '"../Frontend/node_modules/@angular/platform-browser/platform-browser"' has no exported member 'HammerLoader'." pacakge.json contain with "@angular/platform-browser" and "@angular/material". I'm trying to use here angular material table. I couldn't figure it why this error is coming and the possible solution. 回答1: Check

how to call a function after the termination of another function in angular

给你一囗甜甜゛ 提交于 2019-12-09 09:53:59
问题 I have 3 functions and I would like to call one after the other openTryFunction(){ // function one this.functionOne(); // after function one this.functionTwo(); // after function two this.functionTree(); } 回答1: So you have three functions functionOne , functionTwo , and functionThree . There can be multiple PnCs of whether any of these functions is synchronous or asynchronous. Let's generalize these scenarios into two main categories: All are synchronous : If this is the case, your code is

Angular 6. Is it possible to inject service by condition?

独自空忆成欢 提交于 2019-12-09 09:23:43
问题 In my angular app (with the angular material) I have a filter panel and I want besides select to be able to make autocomplete (user input value and it sends to the back-end, whereby $regexp query we find the match in MongoDB collection). But to do it I need manually inject service into filters component. I didn't find any info on how to do it. I need something like this: if (filters.serviceName) { injector.inject(serviceName); } injector.get(serviceName).find(searchQuery); Is it possible?

Errors: Data path “.builders['app-shell']” should have required property 'class'

我与影子孤独终老i 提交于 2019-12-09 04:05:37
问题 I am getting this error while running my application. Here are the details of my application. I have already tried cache clean. 回答1: In your package.json change the devkit builder. "@angular-devkit/build-angular": "^0.800.1", to "@angular-devkit/build-angular": "^0.10.0", it works for me. good luck. 回答2: Following worked for me npm uninstall @angular-devkit/build-angular npm install @angular-devkit/build-angular@0.13.0 回答3: Everyone here is focusing on downgrading @angular-devkit/build

Module not found ..Cannot resolve module 'rxjs/operators/toPromise with Angular6

喜欢而已 提交于 2019-12-09 03:58:43
问题 I am receiving an error when trying to build my application using angular 6 and have no idea what to do. Module rxjs not found see this Module not found ..Cannot resolve module 'rxjs/operators/toPromise what should i do ? // the contact.service.ts import { Injectable } from '@angular/core'; import { Contact } from './contact'; import { Http, Response } from '@angular/http'; import 'rxjs/add/operator/toPromise'; @Injectable() export class ContactService { private contactsUrl = '/api/contacts';

ngOnChanges not firing if an @Input is receiving an object

亡梦爱人 提交于 2019-12-09 01:38:16
问题 Parent component template: <my-component [param]="whatever"></my-component> Parent component code: whatever = { value1: 0, value2: 1, value3: 'foo' }; Child component code: @Input() public param: any; ngOnChanges() { console.log('Received input: ', param); } This isn't working. Any change to whatever will be unnoticed by the child component and ngOnChanges won't fire. It also doesn't work if I try to use a setter: @Input() set param(value) { console.log(value); } And it doesn't help if I try

rxjs__WEBPACK_IMPORTED_MODULE_3__.Observable.throw is not a function at

六眼飞鱼酱① 提交于 2019-12-08 22:01:08
问题 I need to do rest operation adn catch erro and I do this: import { Injectable, } from '@angular/core'; import { Http, Response,Headers} from '@angular/http'; import { map} from 'rxjs/operators'; import { catchError } from 'rxjs/operators'; import { Observable} from 'rxjs'; @Injectable() export class RESTSERCIVE{ getObject(id: number){ return this.http.get(this.url+"/"+id).pipe(map( (response: Response)=>{return response.json()}, ), catchError(this.handleErrorObservable) ); }