All Questions

245
votes
9answers
252615 views

How can I select an element in a component template?

Does anybody know how to get hold of an element defined in a component template? Polymer makes it really easy with the $ and $$. I was just wondering how to go about it in Angular. Take the example ...
179
votes
8answers
52523 views

Angular - What is the meanings of module.id in component?

In an Angular app, I have seen that @Component has property moduleId. What does it mean? And when module.id is not defined anywhere, the app still works. How can it still work? @Component({ modul...
5
votes
1answers
2005 views

How to pass an expression to a component as an input in Angular2?

I need to pass an expression to a component that will be evaluated inside an component's template. For example, component: @Component({ selector: 'app-my-component', ... }) export class MyCompon...
8
votes
3answers
11588 views

Share data between components using a service in Angular2

I am developing an application using angular2. I have a scenario where I need to pass complex data (array of objects) from one component to another component(they are not parent-child, they are two se...
6
votes
1answers
3585 views

How to use ResolveComponentFactory() but with a string as a key

what I'm trying to do: Use something similar to the "resolveComponentFactory()", but with a 'string' identifier to get Component Factories. Once obtained, start leverage the "createComponent(Factor...
7
votes
2answers
1556 views

ng2 - dynamically creating a component based on a template

I've been looking at the Angular 2 APIs for ComponentResolver and DynamicComponentResolver for creating dynamic components, but I have something different in mind than those APIs offer. Is there any ...
3
votes
3answers
5779 views

angular2 pass ngModel to a child component

I have ParentComponent and a ChildComponent, and I need to pass the ngModel in ParentComponent to ChildComponent. // the below is in ParentComponent template <child-component [(ngModel)]="valueInP...
48
votes
3answers
70652 views

How to call another components function in angular2

I have two components as follow and I want to call a function from another component. Both components are included in the third parent component using directive. Component 1: @component( selector:'c...
6
votes
1answers
6596 views

How to call component method from service? (angular2)

I want to create service, which can interact with one component. All another components in my app, should be able to call this service, and this service should interact with this component. How to ca...
12
votes
3answers
6931 views

Testing ngOnChanges lifecycle hook in Angular 2

Given the following code I try to test the ngOnChanges lifecycle hook of Angular2: import { it, inject, fdescribe, beforeEachProviders, } from '@angular/core/testing'; import {TestCo...

Previous Next