angular5

Import json file in typescript Angular 5

落花浮王杯 提交于 2019-12-13 16:30:38
问题 I am trying to import json file in typescript class like that import * as nationalities from './mock/nationalities.json'; and it gives me an error Cannot find module './mock/nationalities.json'. and to solve this issue I added this declare module '*.json' { const value: any; export default value; } but it doesn't solve my issue and also gives my another error exception Invalid module name in augmentation, module '*.json' cannot be found. My Typescript version 2.9.2 回答1: Based on this post,

Angular 5 Pass data on click event from parent component to child component on button clicked at parent component

北慕城南 提交于 2019-12-13 13:26:09
问题 i have some data bind in table and on click of any specific i want to show current clicked object more related data in to another component(child component) for example the data I'm taking from this link: http://jsonplaceholder.typicode.com/users HTML Code: <table> <thead> <th> Id </th> <th> name </th> <th> username </th> <th> email </th> <th> street </th> <th> suite </th> <th> zipcode </th> <th> phone </th> <th> website </th> </thead> <tbody> <tr *ngFor="let data of httpdata"> <td>{{data.id}

Deploy Angular 5 build:ssr on Azure

纵然是瞬间 提交于 2019-12-13 11:48:15
问题 I've built my project starting form the angular universal template found here: universal-starter I am trying to deploy the ssr build as azure web app. My code is on VSTS. On my local machine I can run the following: npm install npm run build:ssr . This produces the dist folder. I can then copy the dist folder somewhere else and run with the command below node server.js The app starts on port 4000 on local machine. So following the steps above, I've created a build process on my VSTS with the

How to load conditionally templateUrl html file in Angular 5 component

不想你离开。 提交于 2019-12-13 11:36:47
问题 There is one scenario in my project, Consider, I have one testDynamic component @Component({ templateUrl: "./test-dynamic.html", // Need to override this file styleUrls: ['./test-dynamic.css'] }) export class testDynamic { constructor() { } } here need to check if an override1.html file is exists in override folder then load this file as templateUrl otherwise load the component default test-dynamic.html. Any idea how to achieve this.? refer the following image for clearly understanding 回答1:

Set value of <mat-select> programmatically

帅比萌擦擦* 提交于 2019-12-13 11:36:25
问题 I'm trying to set value of 2 fields <input matInput> abnd <mat-select> programatically. For text input everything works as expected however for the <mat-select> on the view this field is just like it would have value off null . But if I would call console.log(productForm.controls['category'].value it prints correct value that I set programmatically. Am I missing something? Here is the code: form config: productForm = new FormGroup({ name: new FormControl('', [ Validators.required ]), category

Persist class property Angular 5

会有一股神秘感。 提交于 2019-12-13 11:01:43
问题 I have an SearchComponent (route: /search) and SearchDetailComponent (route: /search-detail:id). The SearchComponent contains an searchbox (input field) where I can type any text to start a search. Now after loading the search results an navigating to the SearchDetail page, I want to save the search term I typed into the searchbox. But only after routing back from the Detail page. So if I navigate back from detai page, the same text I searched for should be in the searchbox. The searchbox

Download a file from spring boot rest services from angular 5

孤人 提交于 2019-12-13 09:32:39
问题 I have spring boot service which provides csv file as response. How do we call this service from angular 5 typescript. download of a file should happen depends on some input parameters so I will have post call with user clicks the export button. below is the rest code in controller. @Controller public class MyController { @RequestMapping(value = "/downLoadDataQueryCsv", method = RequestMethod.GET) public ResponseEntity<Object> downLoadDataQueryCsv(Model model) throws IOException { FileWriter

What would be the best way to create a form onthe Fly in angular x (2 4 5) and submit it?

女生的网名这么多〃 提交于 2019-12-13 09:09:34
问题 I have an angular x(2 4 5) app, and i must make a post redirect to a bank page, so the user can pay something. So, I want to create a form on the fly in my DOM and post it. Can't find the best way. It's easy to loop and create a form, but not easy to directly post it after drawing it. thanks in advance 回答1: As @DeborahK mentioned, you probably can't directly post an Angular form. However, there's no reason that you can't get the data from the form, and pass it to a service that uses the

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';

How to access any of the element under a directive and add events?

孤者浪人 提交于 2019-12-13 04:42:22
问题 Here is my directive: import { Directive, HostListener, ElementRef, Renderer, Input } from '@angular/core'; @Directive({ selector: '[carouselDirective]' }) export class CarouselDirective { @Input() carouselDirective:any; constructor( private el : ElementRef, private renderer: Renderer ) { console.log(el.nativeElement); //how to add the click / hover events to it's childrens? } @HostListener('click') onClick() { window.alert("onClick"); } @HostListener('mouseover') onHover() { window.alert(