angular6

Angular 6 - Sorting all table columns works on only two columns instead of all

不问归期 提交于 2019-12-14 03:57:17
问题 I'm trying to sort a MatTable with MatSort of angular material but the problem is I can sort only two columns of my MatTable but what I want is to sorting all my columns and I don't understand why it doesn't work... I can click on the arrow like when I want to sort data of my table but nothing happens except with column multiple and occupation which are sorting well. Here is my code (I'm well importing MatSortModule into my app.module.ts ): csr.component.ts import {AfterViewInit, Component,

unable to compile a code when converted into a function

北战南征 提交于 2019-12-14 03:05:15
问题 I have the following piece of code which works correctly. public createData(data:Data):Observable<any>{ console.log('contacting server at '+this.API_URL +this.NEW_DATA_URL +" with data "+data+ " with httpOptions "+httpOptions.withCredentials + ","+httpOptions.headers ); let newData = new Data(data) let body = JSON.stringify(newQuestion); //I WANT TO MOVE THE CODE BELOW INTO A FUNCTION BUT AM GETTING COMPILATION ERROR this.loaderService.show(); return this.http.post(this.NEW_QUESTION_URL,body

Getting error in Angular 6 Cannot read property 'length' of undefined

落花浮王杯 提交于 2019-12-14 01:26:46
问题 Cannot read property 'length' of undefined TypeError: Cannot read property 'length' of undefined at levenshtein (F:\Learnings\AngularHandsOn\Angular6\angular6Handson\node_modules\@angular\cli\models\command-runner.js:58:23) at listAllCommandNames.sort (F:\Learnings\AngularHandsOn\Angular6\angular6Handson\node_modules\@angular\cli\models\command-runner.js:69:43) at Array.sort (native) at Object. (F:\Learnings\AngularHandsOn\Angular6\angular6Handson\node_modules\@angular\cli\models\command

disable menu on login page ionic 4

百般思念 提交于 2019-12-14 00:15:40
问题 I use the beta of ionic 4 for the first time. I try to disable the menu on a login page, but i have some trouble. I've created the app with ionic-cli and the sidemenu template, then I generated a login page. I removed the <ion-split-pane> from the app.component.html I modified the app-routing.module.ts to redirect to my login screen. In my login file, I tried to put an ngOnInit event to disable the menu on this specific page import { Component, OnInit, AfterContentInit, AfterViewInit

@NgModule.entryComponents and Components created dynamically

蓝咒 提交于 2019-12-13 23:29:53
问题 I am opening a Modal in two different ways Stackblitz Example: Calling a method in a component which calls the Modal Service: <button (click)="openModal()">Open Modal</button> export class AppComponent { constructor(private modalService: ModalService) { } openModal() { this.modalService.open(HelloComponent); } } The Modal service creates the component dynamically. Using a directive that then calls the ModalService: <button [modal]="'HelloComponent'">Open Modal</button> @Directive({ selector:

Error trying to diff '[object Object]'. Only arrays and iterables are allowed in angular

怎甘沉沦 提交于 2019-12-13 20:26:36
问题 I'm trying to display the data on the front end but i get the above error. How to resolve this? service.ts rec_source(){ var headers = new HttpHeaders().set('Authorization', 'Token ' + localStorage.getItem('usertoken')); headers.append('Accept', 'application/json'); var options = { headers: headers }; return this.httpClient.get('api/recruit/fetch_recruitment_details',options) } component.ts sources:any = []; constructor(private Authentication:AuthService) { } ngOnInit() { this.Authentication

Many router outlets in Angular 6

送分小仙女□ 提交于 2019-12-13 20:21:55
问题 In my app I have two main parts: Authorization - login and registration pages Panel - basic app pages In my app.component.html I have router outlet for navigation to Authorization and Panel components. However in the mentioned components I have another router outlets for navigation between cards (subcomponents). I tried to do routing separetly for each module, but it doesnt work. When I go to path eg. "/authorization/login" I got error that such url doesnt exists. Here is my app-routing

edit and delete operation in angular

匆匆过客 提交于 2019-12-13 20:06:48
问题 I'm building a crud operation and was able to do the create operation. Now I'm trying to edit and delete them. I tried getting individual data through service but failed. It would be nice if anyone could help me with this. service.ts // Fetch Role Data getRoleData(){ var headers = new HttpHeaders().set('Authorization', 'Token ' + localStorage.getItem('usertoken')); var options_role = { headers: headers }; return this.httpClient.get('api/auth/role/', options_role); } // Add Data sendRole(data)

How to get inner html of Angular6 component and add it to component template?

怎甘沉沦 提交于 2019-12-13 19:17:04
问题 I want to be able to pass components and other html into other components in this way: <app-container-component> <h3>All these items should be displayed in parent component</h3> <app-another-component></app-another-component> </app-container-component> How can I read inner items of container-component and render them inside component template? 回答1: You can use the concept of "@Input","@Output-EventEmitter".By using these properties you can pass data from parent component to child component

RsJX 'Map' operator is not working in Angular 6

∥☆過路亽.° 提交于 2019-12-13 18:15:47
问题 I'm trying to use map operator from RxJS but it throws an error saying Property 'map' does not exist on type 'Observable'. Here is the code import { Injectable } from "@angular/core"; import { Http } from "@angular/http"; import "rxjs/add/operator/map"; @Injectable() export class DataService { constructor(public http: Http) {} getData() { return this.http .get("https://jsonplaceholder.typicode.com/users") .map(res => res.json()); } } 回答1: For first Http is deprecated in higher versions than