angular5

Cannot assign to 'total' because it is a constant or a read-only property

对着背影说爱祢 提交于 2019-12-24 07:53:54
问题 I run ng build --prod in my project. That I found is this error: src\app\components\xxxx\xxxx.component.html(116,100): : Cannot assign to 'total' because it is a constant or a read-only property. In this line I have this code: <input formControlName="total" id="total" type="text" class="validate" [(ngModel)]="total"> I used [(ngModel)]="total" --> because I want the value to be saved even without modifying it. If I used [value]="total" this error doesn't exist, but my value doesn't saved If I

FormControl disabled is not working with logic

只谈情不闲聊 提交于 2019-12-24 07:47:54
问题 I want to make a field disabled from ts file. it is working fine when I true/false statically. but I want to make it logically. when my form in edit mode I will make the fields editable. when the form in view mode will disable the fields. It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true when you set up this control in your component class, the disabled attribute will actually be set in the DOM for you. We recommend using this

Angular 5: Validating disabled fields

北战南征 提交于 2019-12-24 07:02:52
问题 I found this post but it cant solve my problem. I can't validate a simple form with FormControls disabled. I did make a stackblitz example here, please check out my code and verify that is impossible to verify the value of the name control if it's disabled. Stackblitz code Thank you in advance. 回答1: Solution by @Eliseo: If you want not loose the validate you can use [attr.disabled]="true" (or any condition). This give your control an apparence of disabled but still is "validating". 来源: https:

Bootstrap 4 navbar is not working with angular 5

ε祈祈猫儿з 提交于 2019-12-24 06:23:08
问题 Hi, I am trying to add bootstrap with angular project and the styling is not reflecting in the browser. The details are as below. Versions: Angular CLI: 1.7.3 Node: 9.7.1 OS: win32 x64 Angular: 5.2.8 installed bootstrap and jquery using angular cli "bootstrap": "^4.0.0" "jquery": "^3.3.1" in .angular-cli.json added as below "styles": [ "styles.css", "../node_modules/bootstrap/dist/css/bootstrap.min.css" ], "scripts": [ "../node_modules/jquery/dist/jquery.min.js", "../node_modules/bootstrap

Use AngularCLI to generate components when there are multiple apps in your project

人走茶凉 提交于 2019-12-24 03:34:25
问题 My .angular-cli.json file looks like this: { "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "project": { "name": "suman-chrome-extension" }, "apps": [ { "root": "src", "outDir": "dist", "assets": [ "assets", "favicon.ico" ], "index": "index.html", "main": "main.ts", "polyfills": "polyfills.ts", "test": "test.ts", "tsconfig": "tsconfig.app.json", "testTsconfig": "tsconfig.spec.json", "prefix": "app", }, { "root":"blank-page-src", "outDir": "blank-page-dist", "index": "page

Setup Server Side Rendering Angular 4+ Application with Loopback/Strongloop

点点圈 提交于 2019-12-24 03:23:46
问题 I have a Loopback-Server as backend for my angular application and it works great. To improve my SEO on my application I want to render the application on the server (ssr). I have my angular application inside the client folder of the loopback server application the /client/dist folder is where the generated angular files are stored. the /client/frontend folder is where the source application is in. my question is how to setup the tsconfig.json file. my angularCompilerOptions look like this:

Html to pdf using jsPDF rtl support

强颜欢笑 提交于 2019-12-24 02:09:07
问题 I am trying to convert html to pdf with jsPDF using angular 5 Here is my code: import * as jsPDF from "jspdf"; . . . htmlToPdf(){ var doc=new jsPDF(); var specialElementHandlers = { '#content' : function(element,render) {return true;} }; doc.fromHTML(document.getElementById('content'), 20,20,{ 'width':500, 'elementHandlers': specialElementHandlers, }); doc.save('Reports.pdf'); } I am trying to export the pdf with direction right to left without sucsses When I try this command: doc

Angular 5.2 & RxJS 5.5 HttpInterceptor retryWhen, but update request?

隐身守侯 提交于 2019-12-24 02:07:27
问题 I am trying to intercept a 401 response, send a refresh token request before trying request again (but with a different header). I have it working except retryWhen does not give me to modify the original request header. So I've been trying to use catchError instead but I cannot seem to execute the request again. Here is my current retryWhen : import {Injectable} from '@angular/core'; import { HttpInterceptor, HttpHandler, HttpRequest, HttpEvent, HttpErrorResponse } from '@angular/common/http'

AppInjector get is deprecated, use Type<T> or InjectionToken<T>

蓝咒 提交于 2019-12-24 00:42:56
问题 I am trying to get rid of this tslint warning: WARNING: get is deprecated: from v4.0.0 use Type or InjectionToken The way I have my code setup is like this: app.injector.ts import { Injector } from '@angular/core'; export let AppInjector: Injector; export function setAppInjector(injector: Injector) { if (AppInjector) { // Should not happen console.error('Error: AppInjector was already set'); } else { AppInjector = injector; } } app.module.ts ... import { setAppInjector } from './app-injector'

Reuse individual Angular 5 reactive form elements

会有一股神秘感。 提交于 2019-12-24 00:26:18
问题 I am still learning Angular 5 and have started working with the "reactive" form model. However, almost every example and tutorial I can find has you creating the entire form in one template. Normally in AngularJS 1.x, we would store each field in its own directive and then wire them together to create a form to cut down on duplication. Is there a way to do this with Angular 5 reactive forms using only one file and having the template and all validations included? I can see how to do it in two