angular5

Invoking a function with dependencies in Angular

一世执手 提交于 2019-12-23 20:32:43
问题 Using Angular 5 and UIRouter state routing. I'm using an additional custom route state property as per this interface. interface AugmentedNg2RouteDefinition extends Ng2StateDeclaration { default?: string | ((...args: any[]) => string | Promise<string>); } When I define an abstract state, I can now add a default property to it as well, so when one would try to route to an abstract state, the default should redirect them to configured default child state. As can be understood from the interface

Multiple Conditions in ngIf in Angular 6

给你一囗甜甜゛ 提交于 2019-12-23 19:33:34
问题 I want to hide one div and want to show another for that I have written below code My Code My problem is I have used multiple conditions in ngIf but not working properly. Once I click on "Show sub content1" want to hide main content and want to show "Sub Content 1" and vise versa for all buttons. What should I do for this. Please help. 回答1: Your were just near to your result and looking into your code looks like you are learning, Good Work!! you have to check just if any one of the content is

Angular HttpClient doesn't send POST, it sends OPTIONS

情到浓时终转凉″ 提交于 2019-12-23 17:57:39
问题 Im' newbie using Angular HttpClient (and writting english too) I have a problem, I'm trying sending HTTP request with POST method in order to negociate OAuth token obtenction but angular sends OPTIONS request: Service: login(username: string, password: string) { const body = `username=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}&grant_type=password`; const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization

How to preventDefault() in HostListener Input action

末鹿安然 提交于 2019-12-23 13:05:50
问题 Im trying to write a directive that limit user to input numeric only characters in the input text control. @Directive({ selector: '[numericControl]' }) export class NumericControlDirective { contructor( private el: ElementRef, ) {} @HostListener('input', ['$event']) onInput(e: any) { if (e.which < 48 || e.which > 57) { e.preventDefault(); } } } Usage <input type="text" placeholder="Volume" numericControl /> But it doesn't work, Anyone came across this issue? 回答1: Use Keyboard event type -

Bind image from service in angular 6

二次信任 提交于 2019-12-23 12:40:37
问题 I have an endpoint that provides me an image based on certain parameter. It's not an image url, its a plain image. So when i hit the endpoint in postman, in response, i receive an image (JPG). I do i receive this image in a variable and bind it in tag of HTML? All the questions have solution for mapping an image url to image, whereas mine is an image which i have to display in UI. show-image-component.ts this.appservice.getImage().subscribe((image) => { console.log(image); } ) service.ts

observable subscription does not work when written in ngOnit() in IE

巧了我就是萌 提交于 2019-12-23 11:46:22
问题 I have defined a behavior subject: component.ts bsub1: BehaviorSubject<Array<any>> = new BehaviorSubject(null); And called next() on it: html: <button (click) = getData()>Data</button> component.ts: getData() { getSomething(value, bsub1); } service.ts getSomething(value, _observable) { //do something _observable.next(retun) somevariable.map(p => { return { "a": value1, "b": value2 } }); } And made a subscription: component.ts ngOnInit() { bsub1.subscribe(list=>{ console.log("subscribed to

observable subscription does not work when written in ngOnit() in IE

落花浮王杯 提交于 2019-12-23 11:46:14
问题 I have defined a behavior subject: component.ts bsub1: BehaviorSubject<Array<any>> = new BehaviorSubject(null); And called next() on it: html: <button (click) = getData()>Data</button> component.ts: getData() { getSomething(value, bsub1); } service.ts getSomething(value, _observable) { //do something _observable.next(retun) somevariable.map(p => { return { "a": value1, "b": value2 } }); } And made a subscription: component.ts ngOnInit() { bsub1.subscribe(list=>{ console.log("subscribed to

Angular 5 Stagger Animation - How to do Reverse Order

♀尐吖头ヾ 提交于 2019-12-23 10:17:05
问题 While working with Angular CDK and developing a custom component, I am trying to implement stagger animation with ngIf and ngFor . The animation is a sequence of simple fade in. The following simplified HTML: <button (click)="visible = !visible">Toggle</button> <div class="parent" @parentAnimation *ngIf="visible"> <p class="child">Child 1</p> <p class="child">Child 2</p> <p class="child">Child 3</p> </div> And Component: @Component({ selector: 'my-app', templateUrl: './app.component.html',

Angular-universal getting error: You must pass in a NgModule or NgModuleFactory to be bootstrapped

核能气质少年 提交于 2019-12-23 06:48:45
问题 I converted my existing angular-cli application to angular-universal by following this guide. You can look at my complete source code here. I am able to build both browser and client projects but I get following error when I view the app in the browser: Error: You must pass in a NgModule or NgModuleFactory to be bootstrapped at View.engine (D:\ng-ssr-demo\dist\server.js:359545:23) The issue is in my server.ts file where AppServerModuleNgFactory is being undefined and as this factory is used

Angular 5 :: JSON parse error while saving

蹲街弑〆低调 提交于 2019-12-23 04:47:50
问题 I have two entities in @OneToMany relationship : @Entity public class Contact implements Serializable{ @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name = "id", updatable = false, nullable = false) /*.................*/ @ManyToOne @JoinColumn(name = "fk_company") @JsonBackReference private Company company; } @Entity public class Company implements Serializable{ @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name = "id", updatable = false, nullable = false)