angular-components

Angular 2 'component' is not a known element

五迷三道 提交于 2019-11-27 17:33:58
I'm trying to use a component I created inside the AppModule in other modules. I get the following error though: "Uncaught (in promise): Error: Template parse errors: 'contacts-box' is not a known element: If 'contacts-box' is an Angular component, then verify that it is part of this module. If 'contacts-box' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. My project structure is quite simple: I keep my pages in pages directory, where each page is kept in different module (e.g. customers-module) and each module has

How to execute a function from another component that is NOT a sibling of the first component?

时光总嘲笑我的痴心妄想 提交于 2019-11-27 15:47:52
I'm trying to execute a function from another component ( These 2 components are NOT siblings ). My guess is that I will need to use @Output and eventEmitter to accomplish this or create a Service and subscribe to the Observable to share the same data throughout all the components (I know how to pass a message( string) but I don't know how to execute a function). I'm not really sure where to start. I'm trying to execute function1 FROM function2 . Can anyone help me on how to get this to work? Please provide a plunker . This is what my project looks like: src |__app(FOLDER) |__home(FOLDER) | |

How to load different global css styles for different environments with Angular 2

扶醉桌前 提交于 2019-11-27 06:57:26
问题 I would like to load different global css styles for different environments. In angular-cli.json it is "hardcoded" to "styles.css". Is there a way to load different css file - based on some property defined in environment? 回答1: Based on user1964629 's answer I came up with the following solution I have a white label web-app that I wanted to apply a different themes to based on which client it was for. First I made two different apps in the angular-cli-json file. I basically duplicated the one

How add class to parent in angular application?

人盡茶涼 提交于 2019-11-27 06:24:32
问题 I have next HTML // This is parent <div class="some-class"> // This is child <totalizer</totalizer> </div> How can I change parents style ( add new class ) from child? 回答1: You can use an EventEmitter @Output() property that signals the parent component to add/remove a css class dynamically using ngClass . In your child totalizer component, define, @Output() cssRefresh = new EventEmitter<boolean>(); //when you need to add/remove css emit an event out to the parent like this // (preferably in

Angular 2: How to style host element of the component?

醉酒当歌 提交于 2019-11-26 23:33:35
I have component in Angular 2 called my-comp: <my-comp></my-comp> How does one style the host element of this component in Angular 2? In Polymer, You would use ":host" selector. I tried it in Angular 2. But it doesn't work. :host { display: block; width: 100%; height: 100%; } I also tried using the component as selector: my-comp { display: block; width: 100%; height: 100%; } Both approaches don't seem to work. Thanks. There was a bug, but it was fixed in the meantime. :host { } works fine now. Also supported are :host(selector) { ... } for selector to match attributes, classes, ... on the host

Angular 4 ExpressionChangedAfterItHasBeenCheckedError

空扰寡人 提交于 2019-11-26 20:52:59
问题 in ParentComponent => ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: ''. Current value: '[object Object]'. at viewDebugError (vendor.bundle.js:8962) at expressionChangedAfterItHasBeenCheckedError (vendor.bundle.js:8940) Parent component Html <div> <app-child-widget [allItems]="allItems" (notify)="eventCalled($event)"></app-child-widget> <div> Parent component export class ParentComponent implements OnInit { returnedItems: Array<any> =

How to Update a Component without refreshing full page - Angular

拜拜、爱过 提交于 2019-11-26 19:40:14
My Page structure is: <app-header></app-header> <router-outlet></router-outlet> <app-footer></app-footer> How can I update/refresh the app-header component, without refreshing the whole page? I want to hide a "Sign-In" link in the header, once the user had successfully logged in. The header is common in all the components/routes. You can use a BehaviorSubject for communicating within different components throughout the app. You can define a data sharing service containing the BehaviorSubject to which you can subscribe and emit changes. Define a data sharing service import { Injectable } from '

Call child component method from parent class - Angular

半城伤御伤魂 提交于 2019-11-26 17:33:37
I have created a child component which has a method I want to invoke. When I invoke this method it only fires the console.log() line, it will not set the test property?? Below is the quick start Angular app with my changes. Parent import { Component } from '@angular/core'; import { NotifyComponent } from './notify.component'; @Component({ selector: 'my-app', template: ` <button (click)="submit()">Call Child Component Method</button> ` }) export class AppComponent { private notify: NotifyComponent; constructor() { this.notify = new NotifyComponent(); } submit(): void { // execute child

How to execute a function from another component that is NOT a sibling of the first component?

心不动则不痛 提交于 2019-11-26 17:17:06
问题 I'm trying to execute a function from another component ( These 2 components are NOT siblings ). My guess is that I will need to use @Output and eventEmitter to accomplish this or create a Service and subscribe to the Observable to share the same data throughout all the components (I know how to pass a message( string) but I don't know how to execute a function). I'm not really sure where to start. I'm trying to execute function1 FROM function2 . Can anyone help me on how to get this to work?

Angular 2 &#39;component&#39; is not a known element

ぐ巨炮叔叔 提交于 2019-11-26 15:21:54
问题 I'm trying to use a component I created inside the AppModule in other modules. I get the following error though: "Uncaught (in promise): Error: Template parse errors: 'contacts-box' is not a known element: If 'contacts-box' is an Angular component, then verify that it is part of this module. If 'contacts-box' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. My project structure is quite simple: I keep my pages in pages