angular

Initializing Template Driven Form in Angular 7

柔情痞子 提交于 2021-02-11 06:59:42
问题 I'm looking to initialize certain form fields on a form and then call a function that has a if(this.form.valid) condition on it. on the ngOnInit function I have an API call that gets some basic info and fills it on the form: ngOnInit(){ this.apiService.getInfo(this.user.id).subscribe( userInfo => { this.formModel.fieldA = userInfo.A; this.formModel.fieldB = userInfo.B; this.formModel.fieldC = userInfo.C; this.doStuff(); } ); } However when calling this.doStuff() the form is invalid, even

display form array on selection of dropdwon in angular

时光总嘲笑我的痴心妄想 提交于 2021-02-11 06:52:12
问题 I have a form with following fields: name (textbox), category(dropdown). I want to display a formarray textbox with an add option on selection of dropdwon="3". When i click "add new textfields", new textboxes should be added. Right now i'm showing a textbox (listitem) after selection of dropdown="3". and then on addnewtextfield i'm calling a formarray. Please help me acheive the functionality. Thanks in advance. Updated code in Stackblitz: https://stackblitz.com/edit/angular-ivy-js8tfp?file

display form array on selection of dropdwon in angular

空扰寡人 提交于 2021-02-11 06:52:02
问题 I have a form with following fields: name (textbox), category(dropdown). I want to display a formarray textbox with an add option on selection of dropdwon="3". When i click "add new textfields", new textboxes should be added. Right now i'm showing a textbox (listitem) after selection of dropdown="3". and then on addnewtextfield i'm calling a formarray. Please help me acheive the functionality. Thanks in advance. Updated code in Stackblitz: https://stackblitz.com/edit/angular-ivy-js8tfp?file

How to format Angular Material date-picker inside Formly form for service layer (not display format)

杀马特。学长 韩版系。学妹 提交于 2021-02-11 06:51:25
问题 I would like to expose my date value as date only ("yyyy-MM-dd") on an Angular Material date picker. Currently, the default date value is an ISO format (includes time). I have a starter Stackblitz project with the the required setup. The formly-datepicker.type is where I would like to centralize the conversion so that any date used in the model will be formatted properly for the service layer. One of my attempts to accomplish it in a centralized manner is using the Angular

How to run ng serve with PathLocationStrategy while falling back to index.html when page is refreshed

情到浓时终转凉″ 提交于 2021-02-11 06:48:15
问题 For some reasons (e.g Hiding the # from the user), we would like to use PathLocationStrategy as the routing strategy for our Angular 8 Application. We are about to fallback to index.html while deploying the application to an Nginx server. But the problem we are facing is, when we run ng serve locally, the application won't bootstrap when page is refreshed. I have tried to use a custom webpack config to enable devServer.historyApiFallback, it doesn't work. I have also read through quite a few

Angular material Table with expandable rows, automaticly expanded when change tabs With stackBlitz example

你说的曾经没有我的故事 提交于 2021-02-11 06:35:48
问题 I have an Angular material table with expandable rows. In every row, I have multiple tabs, On the first tab, I have another table with expandable rows. At the start al the rows are collapsed, so far so good. When I click a row, the row is expanded, again so far, so good. When I change tabs and come back, all my rows are expanded. How can I solve this issue? The HTML code is like Angular material describes on their page for a table with expandable rows. I created a StackBlitz with my problem,

Create angular lib inside folder

拜拜、爱过 提交于 2021-02-11 06:11:35
问题 Hi I am currently using angular 8 with cli version 8.3.17. I am trying to create an library inside a libs folder instead of the normal projects folder I tried running: ng g lib libs/test** but I get the error: Project name "libs/test" is not valid. New project names must start with a letter, and must contain only alphanumeric characters or dashes. When adding a dash the segment after the dash must also start with a letter. libs/test 回答1: In your angular.json, you can change "newProjectRoot"

how to make angular links work without starting from root URL?

南楼画角 提交于 2021-02-11 06:01:15
问题 I need to create on-demand URLs like these mysite.com/link1 mysite.com/link2 mysite.com/link3 ... I prefer to use angular project but at last, I ended up in such these URLs : mysite.com/#/Link1 mysite.com/#/Link2 ... How can I remove the # and please pay attention to the problem that these URLs should be sent by email so the user can click on them? 来源: https://stackoverflow.com/questions/59915847/how-to-make-angular-links-work-without-starting-from-root-url

how to make angular links work without starting from root URL?

走远了吗. 提交于 2021-02-11 06:01:05
问题 I need to create on-demand URLs like these mysite.com/link1 mysite.com/link2 mysite.com/link3 ... I prefer to use angular project but at last, I ended up in such these URLs : mysite.com/#/Link1 mysite.com/#/Link2 ... How can I remove the # and please pay attention to the problem that these URLs should be sent by email so the user can click on them? 来源: https://stackoverflow.com/questions/59915847/how-to-make-angular-links-work-without-starting-from-root-url

How to cut short long strings while rendering using Typescript

蓝咒 提交于 2021-02-11 05:59:44
问题 I'm sorry for asking a very stupid question. It should be very easy but I'm not able to do this. I'm creating a minimal working model on stackblitz. So, I've a string array containing some information about me (say). I want to display them one by one using ngFor . But there will be some elements whose strings are very long. For eg: The string is: Apple, Ball, Cat, Dog, Elephant, Fish, Goat, Hen, Ink, Jackal, Kite The displayed text should be: Apple, Ball ... That means after the second comma