angular2-components

How to refresh a component from another in angular?

别等时光非礼了梦想. 提交于 2021-02-11 17:54:50
问题 I am currently learning angular and developing a small application a long the way. My application contains multiple components, some of which allowing the use to perform some crud operations. However, I am facing a problem that I have not been able to solve for days now. The app classify the data in different categories which the user can update. But when the user update the data in one component and then navigates to another. The component the user navigates to does not know of the update

Angular 2 can't find a component declared in my feature module

帅比萌擦擦* 提交于 2021-02-07 12:18:35
问题 I'm having a tough time getting modules to work in Angular 2. I have created a plunk that demonstrates the problem. In the plunk, you'll see I have app.module. This module imports app-common.module, which contains a component to display page headers. The template for the top level component, app.component contains the selector for this component. Here's app.common.module: @NgModule({ imports:[CommonModule, FormsModule], declarations: [PageHeaderComponent] }) export class AppCommonModule { }

Angular 2 can't find a component declared in my feature module

烈酒焚心 提交于 2021-02-07 12:16:31
问题 I'm having a tough time getting modules to work in Angular 2. I have created a plunk that demonstrates the problem. In the plunk, you'll see I have app.module. This module imports app-common.module, which contains a component to display page headers. The template for the top level component, app.component contains the selector for this component. Here's app.common.module: @NgModule({ imports:[CommonModule, FormsModule], declarations: [PageHeaderComponent] }) export class AppCommonModule { }

Angular 2 can't find a component declared in my feature module

不羁岁月 提交于 2021-02-07 12:16:31
问题 I'm having a tough time getting modules to work in Angular 2. I have created a plunk that demonstrates the problem. In the plunk, you'll see I have app.module. This module imports app-common.module, which contains a component to display page headers. The template for the top level component, app.component contains the selector for this component. Here's app.common.module: @NgModule({ imports:[CommonModule, FormsModule], declarations: [PageHeaderComponent] }) export class AppCommonModule { }

Angular 2 SVG not rendering

微笑、不失礼 提交于 2020-12-11 02:37:10
问题 I created a component to render SVG images that are within my app. The are loaded dynamically as the however, my demo app just show a simpler version. http://plnkr.co/edit/g2tZXeUAMJ5zESx2EHT0?p=info i tried <div [innerHTML]="data"></div> and <div> {{ data }} </div> The SVG is not being loaded though the call is correct. I spent sometime in gitter to find a solution but the closest i got was it it's being sanitzed. The innerHTML i assume is being sanitzed and the interpolation is being

Can component invoke a self destroy event

自古美人都是妖i 提交于 2020-05-24 19:22:45
问题 I have a parent component which opens a new component on click of a link, this new component is supposed to have a close button which on close sends a closing message to parent and destroy itself. We can send the closing message using ngOnDestroy method, but how do I invoke the destroying of the child component. <parent> <child></child> //child to be opened on click but close //event should be inside the child componenet </parent> Do correct me if i am having some conceptual mistake here.

Angular 2 dynamically set routerLink using a component property

ε祈祈猫儿з 提交于 2020-01-24 03:45:33
问题 I have created an component that contains a element with a routerLink property which I want to set from a template that uses the component. When I try to do this I get the error message 'Cannot read property 'path' of undefined'. My component looks link this: info-box.component.ts import { Input, Component } from "@angular/core"; import { ROUTER_DIRECTIVES } from "@angular/router"; @Component({ selector: "info-box", template: require("./info-box.component.html"), directives: [ ROUTER

Angular 2, Cant able to access a variable in one Component from another Component

我的未来我决定 提交于 2020-01-03 17:25:30
问题 Sorry if this is a duplicated question, I have searched solution throughout the Web can't able to find any so am posting it, Am trying to access a variable from one component inside another component What I have Tried I have created a model of object type and have set the value inside a component A method, and tried to access that model object from component B so that I can set the value for the Component B Elements, but getting object as undefined Problem Component A is loaded first in

Angular2: Pass by reference to interact between components

霸气de小男生 提交于 2019-12-30 04:00:09
问题 When we pass a model to the child component and it modifies it, the values are just reflected in the child components' local variable and not available to the parent. Can we pass values by reference from parent to child. So the changes are visible there as well. I have implemented the same using an observable at the service layer. But can't we pass by reference through @Input ? 回答1: Primitive values ( string , num , boolean , object references) are passed by value (copied), objects and arrays

Testing ngOnChanges lifecycle hook in Angular 2

送分小仙女□ 提交于 2019-12-29 05:41:35
问题 Given the following code I try to test the ngOnChanges lifecycle hook of Angular2: import { it, inject, fdescribe, beforeEachProviders, } from '@angular/core/testing'; import {TestComponentBuilder} from '@angular/compiler/testing'; import {Component, OnChanges, Input} from '@angular/core'; @Component({ selector: 'test', template: `<p>{{value}}</p>`, }) export class TestComponent implements OnChanges { @Input() value: string; ngOnChanges(changes: {}): any { // should be called } } fdescribe(