angular8

Angular Viewmodels and usage in components

大城市里の小女人 提交于 2020-01-14 04:08:43
问题 I'm trying to bind viewmodels to a view through component. Initially I did this in the component and it was almost working: model: any = { TenantId: '', CustomFieldName: '', quantities: [] }; quantity: any = { price: '', name: '' } Then on button click for adding new object of model I was doing this: addNewQuantity() { if (this.newQuantity) { this.quantity.name = this.newQuantity; this.model.quantity.push(this.quantity); this.newQuantity = ''; } } The issue with above event was that the same

Function DocumentReference.set() called with invalid data

半腔热情 提交于 2020-01-11 13:19:10
问题 I'm trying to upload an image and a title from an angular website to firestore. This is my template. <form #form="ngForm" autocomplete="off" (submit)="onSubmit(form)"> <div class="form-group"> <input type="text" name="title" id="title" #title="ngModel" [(ngModel)]="service.timetable.title"> </div> <div class="form-group"> <input hidden type="text" name="id" id="id" #id="ngModel" [(ngModel)]="service.timetable.id"> </div> <div class="form-group"> <input hidden type="text" name="imgurl" id=

Data is unknown / Cannot be fetched when link is clicked after implementing 'route-outlet'

孤街浪徒 提交于 2020-01-06 08:21:54
问题 I have this navbar, when I refresh the table, the data is fetched but when I move from links to links and go back to the link where the table is located. the data is not fetched or unknown. The problem occurs after I implemented the routers of the page. How can I fetch the data normally even I go back and forth with the links from the navbar. Im using firebase as my database here is the app-routing.module.ts import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '

Angular 8 - httpClient Get method transforms to Options method

风格不统一 提交于 2020-01-06 08:12:19
问题 I am trying to send Get request to my server(Microsoft 2012). I have already added this solution. But in this is solution my get request transformed to Options method. const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/vnd.sas.datamgmt.jobflow.metadata+json; charset=utf-8', 'Authorization': 'Basic' + btoa('username:password') }) }; I also added: httpOptions.headers.set('username', 'password'); httpOptions.headers.append('Access-Control-Allow-Origin', '*');

Getting “error TS2554: Expected 1 arguments, but got 0.” when calling a constructor

天涯浪子 提交于 2020-01-06 08:09:11
问题 Getting an error error TS2554: Expected 1 arguments, but got 0. when the class instance is called. How can I fix this? class ErrorHandler { constructor(private errorService: BackendErrorsService) {} getError() { console.log('error called'); } } const instance = new ErrorHandler().getError(); 回答1: Angular automatically resolve dependencies of components and services. However, when you call your class like that: const instance = new ErrorHandler().getError(); Then you need to supply a

Directive unit testing fails

筅森魡賤 提交于 2020-01-06 06:54:07
问题 I am using jest.js for testing with my angular app. here is the directive I use in html: <textarea errorHighlighter formControlName="Url" name="Url" cols="50" rows="5" placeholder="Enter Page URL" (ngModelChange)="pageUrlChanges($event)"></textarea> here is my directive.ts file: import { Directive, ElementRef, SimpleChanges, HostListener, Renderer2 } from '@angular/core'; import { NgControl } from '@angular/forms'; @Directive({ selector: '[errorHighlighter]' }) export class

Function DocumentReference.set() called with invalid data

喜你入骨 提交于 2020-01-06 04:31:40
问题 I'm trying to upload an image and a title from an angular website to firestore. This is my template. <form #form="ngForm" autocomplete="off" (submit)="onSubmit(form)"> <div class="form-group"> <input type="text" name="title" id="title" #title="ngModel" [(ngModel)]="service.timetable.title"> </div> <div class="form-group"> <input hidden type="text" name="id" id="id" #id="ngModel" [(ngModel)]="service.timetable.id"> </div> <div class="form-group"> <input hidden type="text" name="imgurl" id=

Store and Use Regex Const Validator in Angular 8 Reactive Formbuilder

拥有回忆 提交于 2020-01-05 07:13:36
问题 How do I store a Regex Validator pattern for reuse and Dry principal in Angular? Have a reactive formbuilder with Regex validator pattern below for ZipCode. Need to apply to multiple address forms, curious how to save /^\d{1,5}$/ So we can write Validators.pattern(zipcode) , or any syntax utilized in Angular? Company has more complicated long patterns for phone numbers, customer number, etc. 'ZipCode': [null, [Validators.maxLength(16), Validators.pattern(/^\d{1,5}$/)]], Looking for a way to

Store and Use Regex Const Validator in Angular 8 Reactive Formbuilder

馋奶兔 提交于 2020-01-05 07:13:08
问题 How do I store a Regex Validator pattern for reuse and Dry principal in Angular? Have a reactive formbuilder with Regex validator pattern below for ZipCode. Need to apply to multiple address forms, curious how to save /^\d{1,5}$/ So we can write Validators.pattern(zipcode) , or any syntax utilized in Angular? Company has more complicated long patterns for phone numbers, customer number, etc. 'ZipCode': [null, [Validators.maxLength(16), Validators.pattern(/^\d{1,5}$/)]], Looking for a way to

How to Upload File from Angular to ASP.NET Core Web API

↘锁芯ラ 提交于 2020-01-03 16:15:04
问题 Similar questions have been asked but after looking through all of those and many blog posts on the subject I have not been able to figure this out so please forgive me. I am creating a simple blog with (for the purposes of this question) two parts, a front end SPA in Angular 8 and a back-end API in ASP.NET Core 3. In one part of my front end I am attempting to upload an image to be used as the image for a newly created blog. When I try to upload an image, the resulting IFormFile in the