angular6

How to run the Dist Folder on Local Machine in Angular 6?

三世轮回 提交于 2019-11-30 10:47:21
问题 I am building the application in Angular, now I have run the command ng build --prod which gave me a dist folder. Now how to check or serve that folder on Localhost ? 回答1: You can do that using http-server. First install the package globally npm install http-server -g . Then inside your project directory(in the terminal) just run http-server dist/ . And if your are using angular 6.x.x, You have to run http-server dist/your-project-name Now you can visit http://localhost:8080 to view your

Angular mat-sidenav property isHandset$ | async explain

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 09:12:50
问题 <mat-sidenav-container class="sidenav-container"> <mat-sidenav #drawer class="sidenav" fixedInViewport="true" [attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'" [mode]="(isHandset$ | async) ? 'push' : 'push'" [opened]="!(isHandset$ | async)"> <mat-toolbar color="primary">Menu</mat-toolbar> <mat-nav-list> <a mat-list-item href="#">Link 1</a> <a mat-list-item href="#">Link 2</a> <a mat-list-item href="#">Link 3</a> </mat-nav-list> </mat-sidenav> I do not understand what is written in

Converting httpClient answer to model objects [Angular 6]

匆匆过客 提交于 2019-11-30 08:56:50
I have a question about the Angular 5 httpClient. This is a model class with a method foo() I'd like to receive from the server export class MyClass implements Deserializable{ id: number; title: string; deserialize(input: any) { Object.assign(this, input); return this; } foo(): string { // return "some string conversion" with this.title } } This is my service requesting it: import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { MyClass } from './MyClass'; @Injectable({ providedIn: 'root', }) export class

How to filter a mat-tree component Angular Material 6.0.1

蹲街弑〆低调 提交于 2019-11-30 07:29:25
I'm using mat-tree angular material component. It's a nice component with some very useful features like, multi-select, expand all/collapse all. I was not able to find any tree filtering feature in any of their APIs. Has anyone came across this feature or done any work around to get mat-tree filter? mfatih I solved the problem by creating a new data source(filtered). stackblitz sample I will explain the example of the shared link: I filtered the data with filter(filterText: string) in ChecklistDatabase and triggered a dataChange event. Then datasource.data was changed by a handled event in

How to create angular 5 project in angular cli 6.0.1

余生颓废 提交于 2019-11-30 07:12:39
My angular cli version is 6.0.1 and node version is 8.11.1 . How to create or add a new project of angular 5. If I use ng new [project_name] then the project is downloading that is of angular 6 . I stumbled upon this scenario too. Here is my solution to it. Unfortunately we are at the CLI's mercy, as the best way to create a new Angular project scaffolding. Considering ng new {app_name} does not support a version flag. Our aim would be to get the right CLI version installed. The following steps helped me workaround this: Create a new folder: mkdir ng-5-cli && cd ng-5-cli Initialise NPM npm

Angular 6: Property 'catch' does not exist on type 'Observable<Response>'?

百般思念 提交于 2019-11-30 07:09:44
问题 I am upgrading my app to Angular 6 . I am upgrading from Angular 4 , but the code below is causing errors in Angular 6, where it worked fine in Angular 4. The errors I am getting: Property 'of' does not exist on type 'typeof Observable' Error: Property 'catch' does not exist on type 'Observable' How should I resolve these errors? private authInterceptor(observable: Observable<Response>): Observable<Response> { return observable.catch((error, source) => { if (error.status == 401) { this.router

Angular 6 - httpClient passing basic auth in httpOptions

不想你离开。 提交于 2019-11-30 06:53:41
I have a service in Angular 6 and I'm trying to change a record but it's saying I'm not authorized. Right now I have this: const httpOptions = { headers: new HttpHeaders({'Content-Type': 'application/json'}) }; update(id, title, content) { const updateData = { id: id, title: title, content: content }; return this.http.put(`http://myurl/${id}`, updateData, httpOptions); } My question is: How to I add basic authorization to my httpOptions or do I add it direct to the update method? You can add basic authorization by appending it in headers, as below: var headers_object = new HttpHeaders();

Angular 6, should I put secret environment variables in environment.ts file?

坚强是说给别人听的谎言 提交于 2019-11-30 06:47:35
There are two sub-questions: Should I put secret environment variables in environment.ts file? The process variable shim is gone. If I use it, tsc will throw an error: Cannot find name 'process' . Here is my thing: About Q1: I don't think put secret environment variables in environment.ts file is correct. Because these files will be a push to source code management, like GitHub, gitlab, bitbucket. It's not safe. So I think secret environment variables should be passed through process.env , like process.env.ACCESS_TOKEN , or, if use docker-compose, should put the secret environment variables in

Angular 6 - Passing messages via service to from component to message component

三世轮回 提交于 2019-11-30 06:39:43
问题 I am trying out how to pass a message from app.component.ts to be displayed in messageComponent.ts on app.component.html I have added <app-messagecomponent></app-messagecomponent> Add the moment it's just showing nothing. I also have a method in a service: message.service.ts message(message) { return message; } So what I want to do to pass a message from other components via the message service so it's displaying in the app-messagecomponent.html For example from app.component.ts:

Ionic 4: “Loading Controller” dismiss() is called before present() which will keep spinner without dismissing

非 Y 不嫁゛ 提交于 2019-11-30 04:59:34
I used "Ionic Loading Controller" to show a spinner until the data is retrieved then it calls "dismiss()" to dismissed it. it works fine, but sometimes when the app already have the data, the "dismiss()" is called before the "create()" and "present()" is done which will keep the spinner without dismissing... I tried to call the data inside "loadingController.present().then()", but that caused the data to be slower... is this a bug? how to solve the this issue? Example of my code: customer: any; constructor(public loadingController: LoadingController, private customerService: CustomerService)