angular6

How can I get reference of child component and emit a value from child component

℡╲_俬逩灬. 提交于 2019-12-11 15:07:29
问题 I have a parent component ValidateSessionComponent which has a child component LoginFormComponent . In my unit test, I want to emit a value from LoginFormComponent but I am unable to figure out how I can do so. The HTML of the ValidateSessionComponent has reference of the LoginFormComponent . <app-login-form #loginForm (formOutputEvent)="handleFormValues($event)" [userId]="username"></app-login-form> The LoginFormComponent looks like export class LoginFormComponent implements OnInit {

Angular: How to display a date in French format

混江龙づ霸主 提交于 2019-12-11 14:33:09
问题 I am an Angular beginner, I read the documentation of Angular, and it's hard for such an elementary thing... I want that the dates and other things in my application have the French locale, and not the default 'en-US'... I started to read this Angular documentation, that seems a little bit incomplete, cause, I did the doc states, and failed: >...\ClientApp>ng serve --configuration=fr Configuration 'fr' could not be found in project 'ClientApp'. OK, now I look on another documentation page on

How to close bootstrap 4 model by calling a function in typescript

我的梦境 提交于 2019-12-11 14:12:13
问题 I am using bootstrap 4 modal followed by the example Below is the template code: <div class="container"> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal"> Open </button> <div class="modal" id="myModal"> <div class="modal-dialog"> <div class="modal-content"> <!-- Modal Header --> <div class="modal-header"> <h4 class="modal-title">Modal Heading</h4> <button type="button" class="close" data-dismiss="modal">×</button> </div> <!-- Modal body --> <div class=

reactive forms - on Submit, check if there is at least one change in the form and only then call the API

我们两清 提交于 2019-12-11 12:13:32
问题 What I want to achieve is something like this: When the user clicks on Submit button, in the background I need to compare if the state of the form has changed, by state I mean if there is at least one change in the form and only then call the API/Server to save information. If there are not any changes, just show a warning message to the user - "Hey you need to update something!"(console.log() is enough) *I also need to handle this case when the user changes something in the field1, for

Can't infer type in the map function

本小妞迷上赌 提交于 2019-12-11 12:04:49
问题 As part of migrating my project from angular 5 to 6 I had to update the way RXJS6 does things. So this this.filteredList = this.autoComplete.valueChanges .startWith(null) .map(val => val ? this.filter(val) : this.list.slice()); changed to this this.filteredList = this.autoComplete.valueChanges.pipe( startWith(null), map(val => val ? this.filter(val) : this.list.slice())); It seems the compiler can't infer type anymore as I get Severity Code Description Project File Line Suppression State

Filters without pipe Angular 6: overriding problem

感情迁移 提交于 2019-12-11 11:36:10
问题 I have 2 categories of filters: group and name . How can I modify this code because they are not working as a pipe, they are independent, and the name filter overrides group filter, and backward. .ts changeGroup(event) { const group = event.target.value; const index = this.groupValue.indexOf(group); if (index > -1) { this.groupValue.splice(index, 1); } else { this.groupValue.push(group); } this.transform(this.usersList, 'group', this.groupValue) if (this.groupValue.length == 0) { this

How to set width of mat-grid-tile

不打扰是莪最后的温柔 提交于 2019-12-11 09:48:31
问题 HTML <mat-grid-list cols="2" [cols]="breakpoint" rowHeight="486px" (window:resize)="onResize($event)"> <mat-grid-tile > </mat-grid-tile> <mat-grid-tile > </mat-grid-tile> </mat-grid-list> How can i give width of 30% for 1st mat-grid-tile 70% for 2nd mat-grid-tile , and how can i set the height of mat-grid-tile equivalent for all the devices? 回答1: You can add colspan . Make sure that the sum of col span is equal to cols Size. <mat-grid-list cols="4" rowHeight="2:1" > <mat-grid-tile colspan="3"

Angular 6 and PHP looping over json array sent through HttPClient giving invalid argument in foreach loop

霸气de小男生 提交于 2019-12-11 09:03:25
问题 I am sending an array with other data using HttpClient of angular 6. And as it's mentioned in this post on github, sending arrays with HttpClient is still not available, so I had a problem reading arrays when received in PHP and var_dump showed me null objects. I found a solution by transforming the array into JSON using json.stringify(array) and it worked, as the received array is properly shown in var_dump : this.auth.saveUnitData( unit_type, location_id, user, number_of, status, add_date,

Angular 6: Can't bind to 'FormGroup' since it isn't a known property of 'form'

久未见 提交于 2019-12-11 08:59:18
问题 I am new to Angular 6 and working on ReactiveForms. Getting this error and unable to compile. I have seen the different solutions and Added the ReactiveFormsModule directive in Imports as suggested in solutions still it is showing the same error. Please Help. Sharing you the desired code and screenshot of the error. app.module.ts import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { SignupFormComponent } from './signup-form/signup-form.component'; import { AuthorsService

Angular 6 difference between .env vs environment.ts

给你一囗甜甜゛ 提交于 2019-12-11 08:26:51
问题 I generated a project from https://mean.io. But I am not sure what the difference is between (.env and .env.example) and (environment.ts and environment.prod.ts). Where should I store all of my config data, secrets, and keys? 回答1: You should store them in the environment.ts environment.ts If you refer environment object properties in your Angular project, during development mode i.e. ng serve or ng build all values shall be read from this file. environment.prod.ts When you build your