angular-event-emitter

How can I change the css style in another component by clicking the button?

孤街浪徒 提交于 2021-01-28 20:36:24
问题 I have developed a component test1 which contains a button and a <p>Hello World</p> . When I click on the button the background color of the paragraph changes. But now I want to change the background color in app.component when I click on the button. I tried to solve the problem with @Input, but unfortunately it does not work yet. Can you please help me? My Stackblitz My code: // test1.component // HTML <button type="button" (click)="testHandler()">Change Color</button> <p [class.toggled]=

How can I change the css style in another component by clicking the button?

左心房为你撑大大i 提交于 2021-01-28 19:42:35
问题 I have developed a component test1 which contains a button and a <p>Hello World</p> . When I click on the button the background color of the paragraph changes. But now I want to change the background color in app.component when I click on the button. I tried to solve the problem with @Input, but unfortunately it does not work yet. Can you please help me? My Stackblitz My code: // test1.component // HTML <button type="button" (click)="testHandler()">Change Color</button> <p [class.toggled]=

Asynchronous call in angular using event emitter and services for cross-component communication

戏子无情 提交于 2020-05-28 06:39:27
问题 cannot store the value received from subscribe method in a template variable. photo-detail component import { Component, OnInit, Input } from "@angular/core"; import { PhotoSevice } from "../photo.service"; import { Photo } from "src/app/model/photo.model"; @Component({ selector: "app-photo-detail", templateUrl: "./photo-detail.component.html", styleUrls: ["./photo-detail.component.css"] }) export class PhotoDetailComponent implements OnInit { url: string; constructor(private photoService:

Angular 5 Pass data on click event from parent component to child component on button clicked at parent component

北慕城南 提交于 2019-12-13 13:26:09
问题 i have some data bind in table and on click of any specific i want to show current clicked object more related data in to another component(child component) for example the data I'm taking from this link: http://jsonplaceholder.typicode.com/users HTML Code: <table> <thead> <th> Id </th> <th> name </th> <th> username </th> <th> email </th> <th> street </th> <th> suite </th> <th> zipcode </th> <th> phone </th> <th> website </th> </thead> <tbody> <tr *ngFor="let data of httpdata"> <td>{{data.id}

How to notify dump component when a http call is failed?

六月ゝ 毕业季﹏ 提交于 2019-12-12 00:53:57
问题 Currently I have a smart component products.component.ts and one dump component products-create.component.ts . The dump component emits an event to the smart component when the user submits on create button. The products.component.ts makes a http call to save the product in the server. Now what i need to know is, how to notify the dump component that the service call is succeeded or failed? The dump component should show the error when failure and navigate to list component while success. 回答1