angular-components

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

What is the proper way to share data between two components using rxjs ReplaySubject?

£可爱£侵袭症+ 提交于 2019-12-11 17:08:58
问题 I've developed a component with two views. Component A has a contact form, and Component B is the "Thank you" page. Component A: You fill the form and submit it. As soon as the response arrives, a new ReplaySubject value is created. The user will be routed to the component B. Component B: The component is initialized. The component gets the value from the subject. The view is rendered and displays the thank you message. HTTP Call response (Returned after a successful Form data post request):

Angular nested component and reactive forms updating data model

荒凉一梦 提交于 2019-12-11 16:13:59
问题 The problem is that after updating values in my form and then selecting the button to display the form again the values are sometimes there. I have tried to do this in different ways using a BehaviorSubject and also doing it with the EventEmitter. Any help would be appreciated. I have attached the plunker: Plunker Below is the data for my plunker example. this.units = [ { id: 1, name: "Unit 1", alarms: [ { name: "Alarm 1", description: "" }, { name: "Alarm 2", description: "" } ] }, { id: 2,

Load component programmatically in angular 1.6

岁酱吖の 提交于 2019-12-11 14:37:07
问题 I have an AngularJS 1.6 application which has a widget section. The widget section is a row with 3 widget that the end user can configure himself. He's given a list of all available widget, and he can choose which one to place and where. Every widget is a component initialized like so: ( function(angular) { function Module1Controller() { var vm = this; // other stuff here } angular.module("app") .component( "module1", { controller: Module1Controller, templateUrl: 'module1.html' } ); } )

How can I create a container component with two or more content placeholders in Angular?

旧街凉风 提交于 2019-12-11 13:39:36
问题 I have to develop a reusable component similar to this one: It has two container parts that can hold other components unknown at the time, the main content part and the menu part: Googling around, I have found an example that uses the ng-content directive, but I don't know if it can be used more than once or not (it's the first time I use Angular for a project). This is the idea: <!-- WindowComponent --> <div class="window"> <h4>Window title</h4> <ng-content></ng-content> </div> <!-- Content

Pass Razor model to Angular 5 component

冷暖自知 提交于 2019-12-11 09:09:42
问题 I have this in my asp.net razor view: @model IEnumerable<MyClass> <app-root [(myModel)]="'@Model'"></app-root> and this import { Component } from '@angular/core'; import { Input } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styles: [] }) export class AppComponent { title = 'app'; @Input() public myModel: any; ngOnInit() { console.log(this.myModel); } } Output in console says "udefined"... I have tried to name 'myModel' as ngModel, i have tried

styleUrls - Not able to load the css style sheet for the component using relative path in angular 2

人盡茶涼 提交于 2019-12-11 08:14:33
问题 I have a "Hero" component defined under "app/Hero" in angular 2. The hero component as "hero.component.html","hero.component.css" and "hero.component.ts" files defined. the templateUrl works fine but the styleUrls do not load. Resource not found error will be displayed. I referred this link https://angular.io/docs/ts/latest/guide/component-styles.html#!#relative-urls to load styles using relative URLs. @Component({ providers: [HeroService], templateUrl: './Hero.component.html', styleUrls: ['.

Angular2 way to update data in nested component from parent component

北战南征 提交于 2019-12-11 06:50:06
问题 I have two nested components: grid-container and grid-component . In grid-container , the grid-component is initialized as follows: <grid [title]="'This is the grid title'" [data]="data"></grid> Data is initialized. Using events, the updated data in grid-component can be obtained in grid-container . Its obvious until here for me. However, what should we typically do in angular 2 to update data in the nested component ( grid-component in this case) from the container component ( grid-container

angular 2 | @ContentChildren not populated, directive in component

折月煮酒 提交于 2019-12-11 06:49:30
问题 I'm trying to get nested directives from a parent directive with @ContentChildren , but not being populated, occurs when parent directive is placed over a component, component template has child directives. example 1 (@ContentChildren not populated) : https://plnkr.co/edit/Zdxp017V3zwNYTOR11dR?p=preview example 2, works fine : https://plnkr.co/edit/ryIomfokiO40Sw8X6Axd?p=preview there any way to make it work example 1? or wait for "some-component" content? thanks in advance 来源: https:/

Can't resolve all parameters for [Component]

南笙酒味 提交于 2019-12-11 02:35:49
问题 In my generic component I have this squiggly saying: ' Angular: Can't resolve all parameters for BaseCollectionComponent' in [path/base-collection.component.ts: ([object.Object], [object.Object], ?, [object.Object])] ' Here is the code of the component: import {BaseRepositoryService} from '../../services/base-repository.service'; import {Component, ComponentRef, Type, ViewChild, ViewContainerRef} from '@angular/core'; import {BaseComponent} from '../base-component/base.component'; import