angular6

Why can't we use [(ngModel)] and value in same input tag in angular 6

倖福魔咒の 提交于 2019-12-13 17:50:19
问题 My html tag is: <input matInput placeholder="Vehicle Number" name="vehicleNo" [(ngModel)]="vehicleNo" value="vehicle.vehicleNo" > I need to automatically fill the input field and if i enter new thing it need to access in component.ts file. 回答1: In angular if you are using ngModel to bind data then you don't need to use value attribute, it will automatically bind the data. //in ts file export className extends OnInit{ vehicle: any; ngOnInit(){ this.serviceName.functionName().subscribe( data=>{

Execute http request sequentially in Angular 6

假装没事ソ 提交于 2019-12-13 16:25:06
问题 I need to send multiple HTTP PUT request to server sequentially (after the next request is only started after completing the previous request, the number of request is not fixed). If I use the below source code, all request will be sent `listURL.forEach(url => { const req = new HttpRequest('PUT', url, formData, { reportProgress: true}); httpClient.request(req).subscribe(event=>{}); });` Is there anyway to execute the requests sequentially? 回答1: If you are not familiar with rxjs, perhaps you

custom typings files to angular 6

拜拜、爱过 提交于 2019-12-13 15:05:57
问题 I am trying to ad some custom typings definition file in angular but facing some error. in app folder I have external folder in which I have external.d.ts file and below code declare function format(input: string, ...args): string; in tsconfig.json I tried adding "files": ["/app/external/external.d.ts"] but its not working. can somebody give me idea about adding custom typings file to angular 6. 回答1: Add the custom typing file to typeRoots in tsconfig.json in the root folder work for me.

After upgrading to Angular 6, application shows blank white screen

两盒软妹~` 提交于 2019-12-13 13:33:33
问题 I have followed steps given at https://update.angular.io/ After upgrading to Angular 6, application shows blank white screen for all the routes. And also there is no error shown in browser console. Each route redirects to default path http://localhost:4200. But http://localhost:4200/admin is working fine. Can anyone help, what can be the issue? What information you need from me to reproduce the issue? Here is the list of dependencies: "dependencies": { "@angular/animations": "6.0.3", "

ngx-smart-modal - Angular 6

余生长醉 提交于 2019-12-13 13:15:05
问题 I followed this StackBlitz example to add te ngx-smart-modal window. Everything went well, except the component opens on the page instead of in a Lightbox modal pop-up. This example is using Angular 4. Has anybody used this module in Angular 6 successfully? 回答1: For ngx-smart-modal v7.1.0, I simply added the .css or .scss (.scss in my case since that is the default file extension I have setup in my Angular project) file to the styles section of your angular.json. "styles": [ ... "node_modules

Angular 6 custom directive with ng-model

好久不见. 提交于 2019-12-13 10:01:49
问题 This is the directive i have created using Angular 6 myProSupMod.directive('dfct', ['$compile', function ($compile) { return { restrict: 'E', scope: { ngModel: '=' }, template: "<div class='divRow'><div class='divCell label-column'> </div><div class='divCell'><input ng-model='ngModel' /></div></div>", replace: true, require: 'ngModel', link: function ($scope, elem, attr, ctrl) { $compile(elem)($scope.$parent); } } }]) And i'm calling the directive from html like <dfct ng-model="RootObjectName

nested json data minipulation for ngx datatable in angualr -6 / js

主宰稳场 提交于 2019-12-13 08:28:50
问题 I am trying to create a ngx datatable that creates columns dynamically from nested arrays, which with some research is not possible - so to achieve my desired result, I must flatten my nested arrays with the key / values that i need from each nested object into my parent object. I need to manipulate my data so that my end result is a flat array and contains a line item for each object in the nested array earnings with 'abbreviation' being the key and 'amount' being the value.. I.e [ {

The selector “app-root” did not match any elements || angular 6

半腔热情 提交于 2019-12-13 06:29:48
问题 I am new to angular 6 and developing admin panel for teachers. i developed the whole admin panel without any problem. After developing admin client gave me a separate html file for login purpose. that's where the whole problem started. So i decided to do it by routing. I created layout for admin panel as well as the login page. But now i am getting ** "app-root" selector did not match** error. Below is my appComponent typescript import { Component, OnInit, Inject } from '@angular/core';

ERROR in error TS2688: Cannot find type definition file for 'jest'

冷暖自知 提交于 2019-12-13 05:51:05
问题 I have an angular 6 application and I'm using karma + jasmine to run my tests. but when I run ng test I'm getting the following error: ERROR in error TS2688: Cannot find type definition file for 'jest'. Any one knows how to solve this problem? 回答1: I didn't realized that in my tsconfig.spec.jason I was using jest instead of jasmin in types node. Also, I had missing configurations. So, I changed from this: { "extends": "./tsconfig.es5.json", "compilerOptions": { "emitDecoratorMetadata": true,

Angular Datatables - reload data

你离开我真会死。 提交于 2019-12-13 04:57:51
问题 I use angular 6 with angular-datatables. I try to define a "rerender" button in order to reload data like this exemple : https://l-lin.github.io/angular-datatables/#/advanced/rerender My datatable is more complex than the one described in the exemple and I get an issue with individual columns filters use: This is my table before rerender action with filters use, all works fine: But when I use these filters after data are reloaded, this is the result : My non-visible column is now visible and