angular6

Angular 6 Service is undefined after injecting in Interceptor

烂漫一生 提交于 2020-04-11 07:54:33
问题 I can't find any way to inject my AuthService inside ErrorHandlerInterceptor . It returns me either an " undefined " object after injection, or it throws an error. This is my ErrorHandlerInterceptor : import { Injectable } from '@angular/core'; import { AuthService } from '@app/auth.service'; import { StorageService } from '@app/storage.service'; @Injectable({ providedIn: 'root' }) export class ErrorHandlerInterceptor implements HttpInterceptor { constructor(private authService: AuthService,

Mocking a BehaviourSubject in a component test spec

浪尽此生 提交于 2020-04-10 06:15:24
问题 I am trying to mock out a service dependency inside a component test, this service has a behaviour subject property which I'm trying to mock. My service is as follows: export class DatePickerService { public date: moment.Moment; public selectedDate: BehaviorSubject<moment.Moment> = new BehaviorSubject<moment.Moment>(moment()); public changeDate = (date: moment.Moment) => { this.selectedDate.next(date); } } The selectedDate is then subscribed to in my component: ngOnInit() { this

How to set multiple selection in dropdown in ng2-smart-table?

坚强是说给别人听的谎言 提交于 2020-04-10 03:06:07
问题 In my app, I have load dynamic values in dropdown list of ng2-smart-table . Now I have to enable multiple selection in dropdown in ng2-smart-table . Note: Multiple selection in dropdown not for checkbox. 回答1: I think you can try with your own custom editor component. I've added a basic select with a multiple attribute , but you can create a custom component more complex as you prefer. Pass data to your component with valuePrepareFunction and voila. settings.ts private settings = { // Previous

How to set multiple selection in dropdown in ng2-smart-table?

主宰稳场 提交于 2020-04-10 02:59:41
问题 In my app, I have load dynamic values in dropdown list of ng2-smart-table . Now I have to enable multiple selection in dropdown in ng2-smart-table . Note: Multiple selection in dropdown not for checkbox. 回答1: I think you can try with your own custom editor component. I've added a basic select with a multiple attribute , but you can create a custom component more complex as you prefer. Pass data to your component with valuePrepareFunction and voila. settings.ts private settings = { // Previous

How to set multiple selection in dropdown in ng2-smart-table?

僤鯓⒐⒋嵵緔 提交于 2020-04-10 02:58:39
问题 In my app, I have load dynamic values in dropdown list of ng2-smart-table . Now I have to enable multiple selection in dropdown in ng2-smart-table . Note: Multiple selection in dropdown not for checkbox. 回答1: I think you can try with your own custom editor component. I've added a basic select with a multiple attribute , but you can create a custom component more complex as you prefer. Pass data to your component with valuePrepareFunction and voila. settings.ts private settings = { // Previous

click event is not working in innerhtml string angular 6

孤人 提交于 2020-03-23 11:54:30
问题 I am working on an generate dynamic template using angular 6. I have an API that return strings like below: <button type="button" (click)="openAlert()">click me</button> and html <div [innerHtml]="myTemplate | safeHtml"> </div> function is bellow: openAlert() { alert('hello'); } 回答1: You cannot bind angular events directly to innerHTML. Still if you need to attach the event listeners you need to to do it after the html content is loaded. Once the content is set to the variable,

Angular 6 run a function in every X seconds

久未见 提交于 2020-03-21 11:33:54
问题 I have a function called opensnack(text) { ... }; which is opening an angular material snackbar with the given text input. What I want to do is to call this function like every 10 seconds. How should I do this? 回答1: Use interval from rxjs Here's how: import { interval, Subscription } from 'rxjs'; subscription: Subscription; ... //emit value in sequence every 10 second const source = interval(10000); const text = 'Your Text Here'; this.subscription = source.subscribe(val => this.opensnack(text

Angular 6 run a function in every X seconds

烂漫一生 提交于 2020-03-21 11:33:52
问题 I have a function called opensnack(text) { ... }; which is opening an angular material snackbar with the given text input. What I want to do is to call this function like every 10 seconds. How should I do this? 回答1: Use interval from rxjs Here's how: import { interval, Subscription } from 'rxjs'; subscription: Subscription; ... //emit value in sequence every 10 second const source = interval(10000); const text = 'Your Text Here'; this.subscription = source.subscribe(val => this.opensnack(text

Angular component naming limitations - 'selector [your component name] is invalid'

 ̄綄美尐妖づ 提交于 2020-03-18 03:49:28
问题 In Angular 6 (6.0.7) I'm trying to generate a component via the CLI. I type in ng g c t1-2-3-user and get the error message Selector (app-t1-2-3-user) is invalid. Is there something inherently not allowed in this name? I've already created a parent module called t1-myModule via ng g module t1-myModule and it was created successfully. Within that module is where I'm trying to generate this component. I've tried creating a different name like ng g c t1-testComponent and it works fine - so the

Facing issue while migrating angular 5 to angular 6 in .net core 2.1 project.

ⅰ亾dé卋堺 提交于 2020-03-05 08:04:42
问题 We are using angular SPA template. Facing issue while migrating angular 5 to angular 6 in .net core 2.1 project. For now I have updated packages, Old version package.json { "name": "projectname", "private": true, "version": "0.0.0", "scripts": { "test": "karma start ClientApp/test/karma.conf.js" }, "dependencies": { "@angular-redux/form": "^6.7.0", "@angular-redux/router": "^6.4.1", "@angular-redux/store": "6.6.0", "@angular/animations": "^5.2.0", "@angular/cli": "^7.1.2", "@angular/common":