angular6

Angular6 Router navigate to multiple child routes that share the same component

孤街醉人 提交于 2019-12-25 01:49:58
问题 I have multiple child components that share the same component which works fine, however, I cannot route between the pages as it appears Angular suspects the component is already loaded. Is it possible to reload the component when attempting to route to these child routes? const ServicesRouting: ModuleWithProviders = RouterModule.forChild([ { path: '', component: StructureComponent, canActivate: [AuthGuard], children: [ { path: 'services', canActivate: [AuthGuard], component:

How to set startX and endX same as startY to put two table in same row but in separate position using JsPdf in angular 6

巧了我就是萌 提交于 2019-12-25 01:37:30
问题 i want to show two table with different data in same row when we print data in JsPdf. Tried to use startX and Endx but nothing happens i have tried startX and endX different table with different data in for different row but not in same row startY: curruntHeight + 20, startX: 160, endX: 250, margin: 10, willDrawCell: drawCell, i expected it could print table in two different position in same row but got table overlapping eachother 来源: https://stackoverflow.com/questions/56335987/how-to-set

Angular 6 : display comments under section commented

被刻印的时光 ゝ 提交于 2019-12-25 00:24:16
问题 I have crud app , which user can add comments , I want comments to be displayed under each section commented, now all added comments displays below all section. here is components ts import { Component, OnInit } from '@angular/core'; import { Task } from '../model/task.model'; import { Comment } from '../model/comment.model'; import { Router } from '@angular/router'; import { UserService } from '../service/user.service'; import {first} from 'rxjs/operators'; import {FormBuilder, FormGroup,

How to handle 401 unauthenticated error in Angular 6

坚强是说给别人听的谎言 提交于 2019-12-24 22:07:43
问题 I need to direct to login page while my data service response to 401 status(unauthenticated ).Here is my code get_data(url,auth=true){ //......url : url path...... //....auth : true api auth required,false no api required.... var get_url = API_URL + url; var headers = new Headers(); headers.append('Content-Type', 'application/json'); headers.append('Accept', 'application/json'); if(auth==true){ var localStore = JSON.parse(localStorage.getItem('currentUser')); if (localStorage.getItem(

Deactivation of angular router link

回眸只為那壹抹淺笑 提交于 2019-12-24 20:58:40
问题 I am making angular application, where i am using routing and auth guard.. stackblitz app component html <div class="container"> <div class="row"> <div class="col-xs-12 col-sm-10 col-md-8 col-sm-offset-1 col-md-offset-2"> <ul class="nav nav-tabs"> <li role="presentation" routerLinkActive="active" [routerLinkActiveOptions]="{exact:true}"><a routerLink="/">Home</a></li> <li role="presentation" routerLinkActive="active"><a routerLink="/servers">Servers</a></li> <div *ngIf="showUser"> <li role=

How to convert xml file to String in Angular 4, 5, 6?

白昼怎懂夜的黑 提交于 2019-12-24 19:40:42
问题 I have a xml file to my local and I want to choose file from local machine and just get outout as file in string. Sample Input file: <mail> <to>abc@gmail.com</to> <from>xyz@gmail.com</from> <heading>Reminder</heading> <body> Party this week !</body> </mail> Expected output: <mail><to>abc@gmail.com</to><from>xyz@gmail.com</from><heading>Reminder</heading><body> Party this week !</body></mail> 来源: https://stackoverflow.com/questions/54867683/how-to-convert-xml-file-to-string-in-angular-4-5-6

Interceptor not setting the authorization token

こ雲淡風輕ζ 提交于 2019-12-24 19:35:48
问题 Hi I'm trying to write a simple Angular 6 interceptor that adds the jwt token to the header when sending requests. The problem is that the header in the request arrives NULL on the backend, so of course I can't get the authorization token and I'm having trouble figuring out why. I'm pretty sure the problem is in my js code because if I try to send the same request via any REST client I can see the header in my Java code just fine. Here's my js code: import { Component, OnInit } from '@angular

Why attribute selected in <select><option> don't work with ngModel?

懵懂的女人 提交于 2019-12-24 18:43:43
问题 I have a problem with Angular 6: if I use a component based on the <select> element (combo-box), if I use it with the classic way, everything works (notice that I used the selected attribute: the result is that in the template the default option already appears as selected, as I would expect!): <select data-width="200px" title="title" name = "name" > <option value='default' selected>Default</option> <option value='1'>Value 1</option> <option value='2'>Value 2</option> </select> The problem is

Angular 6, Open and Download PDF, Issue in Production

喜欢而已 提交于 2019-12-24 18:25:16
问题 I am trying to open as well as download PDF in angular web application. the code works fine while development and gets the PDF on angular app. But the same doesn't work while build for production and deployed. Shows: "Failed to load PDF document" Code as below: Service.ts export(pdfName) { const httpOptions = {'responseType': 'arraybuffer' as 'json'}; return this.http.get<any>(environment.apiBaseUrl + '/download?path='+policyPath, httpOptions); } Component.ts GetDocument(pdfName:any) { this

How to set Checkbox FormControl for Multiple array control

邮差的信 提交于 2019-12-24 17:50:01
问题 I am trying toggle/check according specific permissions with array set id's - to set permissions for users according to their user role. for an example an admin would have permissions to create users, delete, and update. My struggle with the code i've posted below is that it toggles all permissions instead of ones passed into formControl im not sure if im doing right. public userList: Array < User > ; public principalList: Array < Principal > ; public permissionList: Array < PermissionItem >