angular-components

Observable with Angular 4 , NgFor only supports binding to Iterables such as arrays

痞子三分冷 提交于 2019-12-01 05:38:39
问题 Yes, I see that other people get this error , I just don't quite get how to fix it in my code private _url = 'https://min-api.cryptocompare.com/data/pricemulti?fsyms=BTC,ETH,LTC,EOS,DASH&tsyms=USD' If I didn't have the return it does not crash with the error , but I do want to return the data. I have a component that calls up this method ( in this service ts file ) Subscriber: getAllCoins() { var blah = []; return this.getCoins().subscribe( data => { blah = data; //console.log('subscriber

Vertical tabs with Angular Material

我们两清 提交于 2019-12-01 03:50:18
问题 Using the proper Angular Material directive, how do I change the direction to vertical? Starting with vertical tabs: Then want to drop to content below mat-select dropdown: EDIT: Will be working on adapting https://stackoverflow.com/a/43389018 into my answer, if someone doesn't beat me to it :) 回答1: Wrote angular-vertical-tabs. This simply wraps @angular/material 's mat-selection-list, and uses @angular/flex-layout to reorient for different screens sizes. Usage <vertical-tabs> <vertical-tab

Angular - Component different templates

a 夏天 提交于 2019-12-01 02:49:57
问题 I have a component "course". I use this component to a list. This list sometimes is horizontal and some times is vertical. Can I choose dynamicaly inside the component the template file? @Component({ selector: 'course', templateUrl: getTemplateFile() }) Something like that would be great feature! 回答1: I think that this tutorial is very helpful https://scotch.io/tutorials/component-inheritance-in-angular-2 You can simply extend your base component and overwrite the template. This allows you to

No provider for ControlContainer - Angular 5

有些话、适合烂在心里 提交于 2019-12-01 02:33:44
I am converting a purchased, third-party template into an Angular 5 app, and just ran into an error. I am very new to Angular 5 (I know AngularJS well however) and don't understand what it's trying to tell me? It seems to be related to a button which shows/hides the top navbar. Error Message (from browser): Error: Template parse errors: No provider for ControlContainer ("imalize-styl-2 btn btn-primary " (click)="toggleNavigation()"><i class="fa fa-bars"></i> </a> [ERROR ->]<form role="search" class="navbar-form-custom" method="post" action="#"> <div class="form-gro"): ng:///AppModule

Pass Angular Reactive FormControls to Children Components

ε祈祈猫儿з 提交于 2019-12-01 01:31:07
问题 I have a parent component where I want to create and store my Reactive Form. There will be multiple Form Group instances in a Form Array. I want to pass the Form Controls from each Form Group to a Child Component but am having trouble figuring out how to do this. Here's a Stackblitz demonstrating what I would like to do. Also, some fields will only apply to certain 'makes' of cars which is why i have the following line in my html: <input type="text" *ngIf="car.make != 'ford'" formControlName=

Refactoring Angular components from many inputs/outputs to a single config object

时间秒杀一切 提交于 2019-11-30 17:25:32
My components often start out by having multiple @Input and @Output properties. As I add properties, it seems cleaner to switch to a single config object as input. For example, here's a component with multiple inputs and outputs: export class UsingEventEmitter implements OnInit { @Input() prop1: number; @Output() prop1Change = new EventEmitter<number>(); @Input() prop2: number; @Output() prop2Change = new EventEmitter<number>(); ngOnInit() { // Simulate something that changes prop1 setTimeout(() => this.prop1Change.emit(this.prop1 + 1)); } } And its usage: export class AppComponent { prop1 = 1

Refactoring Angular components from many inputs/outputs to a single config object

喜欢而已 提交于 2019-11-30 16:32:01
问题 My components often start out by having multiple @Input and @Output properties. As I add properties, it seems cleaner to switch to a single config object as input. For example, here's a component with multiple inputs and outputs: export class UsingEventEmitter implements OnInit { @Input() prop1: number; @Output() prop1Change = new EventEmitter<number>(); @Input() prop2: number; @Output() prop2Change = new EventEmitter<number>(); ngOnInit() { // Simulate something that changes prop1 setTimeout

How can I use @HostListener('window:beforeunload') to call a method?

非 Y 不嫁゛ 提交于 2019-11-30 13:29:07
问题 I am trying to call a post method I made myself before my component is unloaded, but it doesn't work. I put a breakpoint on @HostListener and it doesn't break there when I open a different component. I'm using Chrome to debug and I turned on Event Listener Breakpoints for unload and beforeunload, which do break when I open a different component. Am I missing something in my code? import { Component, OnInit, HostListener } from '@angular/core'; Component({ templateUrl: 'new-component.html' })

Angular 2 - Passing data to Child component after Parent initialisation

雨燕双飞 提交于 2019-11-30 10:45:51
问题 I have a parent component which is getting data from a server through a service. I need some of this data to be passed to the Child component. I've been trying to pass this data with the usual @Input() however as I expected the data I'm getting in the Child component is undefined . Example Parent Component @Component({ selector: 'test-parent', template: ` <test-child [childData]="data"></test-child> ` }) export class ParentComponent implements OnInit { data: any; ngOnInit() { this.getData();

AngularJS component: using binding object in controller

好久不见. 提交于 2019-11-30 09:19:39
问题 I use Angular component (first example from this). When I binding object in component, it is accessible in template, but isn't in controller. js: function HeroDetailController() { console.log("Here I want to use hero.name: "); console.log(hero.name); // I want to use binding object in controller, but doesn't work } angular.module('heroApp').component('heroDetail', { templateUrl: 'heroDetail.html', controller: HeroDetailController, controllerAs: 'ctrl', bindings: { hero: '=' } }); html: <hero