angular6

Handling radio buttons with Angular 6

穿精又带淫゛_ 提交于 2021-01-29 07:14:06
问题 I have a list of questions as given below. public questionList = [ { question:{ id: "Q1", query:"query 1" }, options:[ { id: "opt1", text: "Q1_opt1" }, { id: "opt2", text: "Q1_opt2" } ], selected:{ id:"", text:"" } }, { question:{ id: "Q2", query:"query 2" }, options:[ { id: "opt1", text: "Q2_opt1" }, { id: "opt2", text: "Q2_opt2" } ], selected:{ id:"", text:"" } } ]; My intention is to list the questions along with options as radio buttons. Whenever somebody selects an option, the id of the

angular 7 build app - replace assets url with real url

試著忘記壹切 提交于 2021-01-29 05:21:12
问题 In an Angular 7 app i have different assets, images, fonts etc. All are located in src/assets/images or src/assets/fonts, etc I my files i use them like this: <img src="/assets/images/img.png"> angular.json look like this: ..... "assets": [ "src/favicon.ico", "src/assets" ] ..... When building I use: ng build --prod --build-optimizer --deploy-url=https://cdn.domain.com This will replace all the reference to assets resource from this: <img src="/assets/images/img.png"> to this: <img src="https

No provider for ControlContainer Error while using Angular Material Forms with Angular 6

十年热恋 提交于 2021-01-29 03:57:19
问题 I have already written an application using Angular 6 and I am adding Angular material into it. Reactive forms approach is used in existing application I have a login module which has below declaration. @NgModule({ imports: [ CommonModule, RouterModule.forChild([ {path:'login',component:LoginComponent} ]), ReactiveFormsModule, HttpClientModule, MatFormFieldModule, MatInputModule ], declarations: [LoginComponent] }) export class LoginModule { } The Login component has below template - login

Ionic 4 - Two way binding [(ngModel)]

落爺英雄遲暮 提交于 2021-01-28 22:01:19
问题 I'm struggling to use two way binding in Ionic 4. I used to use Ionic 3 and two way binding was super easy, I'm not sure why I'm struggling. In my app.module.ts I import: import { FormsModule } from '@angular/forms'; imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule, RoundProgressModule, FormsModule, HttpClientModule ], On my .ts file for my page, I simply init a variable: user:any = { phone: '', name: '', date: '' } and then I have a function I call to change the format of

Retrieve objects in array if property matches another array

╄→гoц情女王★ 提交于 2021-01-28 16:31:44
问题 I want to create a new array containing contact objects if the value property in contacts matches the values in selectedContact . Any simpler way to do this? selectedContact: number[] = [0,2] //value contacts: Contact[] = [{ firstName:"Dan"; lastName:"Chong"; email:"danc@mail.com"; value:0; }, { firstName:"Mark"; lastName:"Wong"; email:"markw@mail.com"; value:1; }, { firstName:"Layla"; lastName:"Sng"; email:"layla@mail.com"; value: 2; }] Intended final result: newArray = [{ firstName:"Dan";

How do I call a function in a class from another class in Angular 6?

谁说我不能喝 提交于 2021-01-28 08:32:25
问题 Here's my code: import { Component, OnInit, ViewChild } from '@angular/core'; import { AuthService } from '../core/auth.service'; import { MatRadioButton, MatPaginator, MatSort, MatTableDataSource } from '@angular/material'; import { SelectionModel } from '@angular/cdk/collections'; import { OrdersService } from '../orders.service'; export interface DataTableItem { ordersn: string; order_status: string; update_time: number; } @Component({ selector: 'app-home', templateUrl: './home.component

angular 6 service worker dataGroups not working

对着背影说爱祢 提交于 2021-01-28 08:11:06
问题 Hi I am trying to deploy a background Service worker that makes calls to api in some time interval in this case 3s, but it seams not to work, when I go to application I am getting no requests to server. My data group in ngsw-config.json stands: "dataGroups": [ { "name": "app-service-list", "urls": [ "http://localhost:5000/api/TcpCommunication/GetCabinsService" ], "cacheConfig": { "maxSize": 5, "maxAge": "3s", "strategy": "performance" } } ] And when I do http-server -p 8090 web page works,

Dynamically Add Rows Based on Condition Using Reactive Forms in Angular

拟墨画扇 提交于 2021-01-28 08:00:51
问题 Is it possible that i will be able to add rows based on certain condition in Angular reactive forms? If yes, please help me do it. I've already started it in my stackblitz. Please check this link https://stackblitz.com/edit/dynamically-add-rows this.addForm.get("items").valueChanges.subscribe(val => { console.log(val); if (val === true) { this.addForm.get("items_value").setValue("yes"); // How to add row here? this.addForm.addControl(rows, 'rows') } if (val === false) { this.addForm.get(

Use of EventEmitter in service of Angular6

廉价感情. 提交于 2021-01-28 06:43:08
问题 Why Event Emitter can't use in service in angular 6? In Angular documentation they mentioned, "Use in directives and components to emit custom events" 回答1: Because in services all waht you have to do is manipulating data, if you want to notify the data changes you can use Subjet or BehaviorSubjet . EventEmitter is generally used to notify changes from child to parent and as said is supposed to be used only for @Output . please take a look at this link 来源: https://stackoverflow.com/questions

How can I resolve Ionic Uncaught Error: Cannot find module “.” when adding new page?

狂风中的少年 提交于 2021-01-27 13:10:57
问题 Uncaught Error: Cannot find module "." at webpackMissingModule (index.js:3) at e.code (index.js:3) at Object.<anonymous> (index.js:9) at __webpack_require__ (bootstrap ee3a374a94c4cd74e2a6:54) at Object.256 (main.ts:5) at __webpack_require__ (bootstrap ee3a374a94c4cd74e2a6:54) at Object.233 (main.js:412) at __webpack_require__ (bootstrap ee3a374a94c4cd74e2a6:54) at webpackJsonpCallback (bootstrap ee3a374a94c4cd74e2a6:25) at main.js:1 Before adding new bookmarks pages in app, the app working