angular2-components

passing one component data to other component

这一生的挚爱 提交于 2019-12-06 16:17:45
I am getting response from server,I want pass this response to other component for displaying. I tried in one way but getting undefined. Tried this way how to pass one component service response to other component in angular 2 . yesterday got the results faced routing. Changed little bit created separated components. mainsearch.component.ts: export class MainsearchComponent { selected; skipCount: number = 0; errorMessage: string; searchedResults: any; searchObj: Object = { skipCount: this.skipCount }; onChange(newVlaue) { console.log(newVlaue); this.selected = newVlaue; } constructor(private

Angular 2 global component

蹲街弑〆低调 提交于 2019-12-06 07:31:53
My structure is as follows : App *component, module, template* Component 1 *component, module, template* Component 11 *component, module, template* Global Component *component, temaplte, BUT NO MODULE* My App module contains the component 1 and component 11 modules. I declared the global component in the app module, so that I can use it in all my other components. I also exported it in app module. But when I use the selector in the component 11 template, the console says not a known element . I tried importing it in my other components but it says it's already imported, and that I should

Retain data on page reload in Angular 2

a 夏天 提交于 2019-12-06 03:08:16
In my Angular 2 app, I pass in some data to a PageComponent from my HomeComponent which is then saved to a variable inside the PageComponent. Now when I refresh the page I need this data to be retained. Currently I am using session storage, but I was wondering if there is a better way to implement this. Smit Nope, There isn't a other way in this context. Once you refresh all the temporary memory is gone. As you said you are performing session-storage. You may continue with that. You may choose the below. LocalStorage Cookie Session Difference and importance: How to store token in Local or

Angular2 - is it possible to get component class name using selector name

ぃ、小莉子 提交于 2019-12-05 17:21:00
Is it possible to get component class name or component reference using selector name in Angular 2? @Component({ selector: 'selector-1', template: '<h1>Hello</h1>', }) export class Component1 {} @Component({ selector: 'selector-2', template: '<h1>Hello</h1>', }) export class Component2 {} In component 2 is it possible to get the component1 class name using selector "selector-1"? Example: getComponentName(selectorName) { // return component name } getComponentName('selector-1'); Thanks in advance It is possible without additional work only if you do not call enableProdMode : var node = document

Angular 4: Dynamic template with interpolation

一世执手 提交于 2019-12-05 06:16:27
I'm building a data table component that is being designed as very generic component. The idea is to define the table as this: <app-datatable [items]="currentPageResult"> <app-datatable-column attribute="id" header="ID"></app-datatable-column> <app-datatable-column attribute="name" header="First Name"></app-datatable-column> <app-datatable-column attribute="last_name" header="Last Name"></app-datatable-column> </app-datatable> In this way, we can specify the array into the datatable component, and by defining datatable-columns we can decide witch attributes should display the table. Internally

Angular 2 Chrome DOM rendering problems

夙愿已清 提交于 2019-12-05 00:26:49
问题 Our team (not only my computer) has a wierd rendering issue for Angular 2, that only happens in Chrome. Namely, when navigating the app or refreshing in mid app, many of the items in DOM are invisible. EG. paragraphs and headers that have text in them, but the text is not rendered for the end user, but the text is seen in the inspector DOM. The DOM will regain visibility if you edit a random CSS attribute in the inspector. This CSS doesnt even have to be applicable to the invisible DOM item

Angular 2 Header component Title change dynamically according to the state

与世无争的帅哥 提交于 2019-12-04 22:24:42
问题 I have a design using angular 2 where header component, navigation bar component and body component where all other components load. As the picture shows below Header Navigation Where other components load (this section might have nested components/ children components) So here basically, In the header component, I want to show the current state . And in the bottom of the current state, I want to show the previous state of the user. Issues: To implement this I used the component interaction

How to open a Angular component in a new tab?

流过昼夜 提交于 2019-12-04 17:53:14
I have a considerable amount of data to show on the screen. I need to present a simplified list so the user can choose one of the items and see it's details. So imagine I have a component SimpleListComponent, it will hold the data and present a simplified view export class SimpleListComponent{ @Input() data: any[]; } The html <ul> <li *ngFor="let item of data"> <a>{{item.name}}</a> </li> </ul> The user should be able to click on one of the itens and open in a new tab a view with that item's details. So if I have a second Component export class DetailedViewComponent{ @Input() item: any; } <div>

Angular2: what expressions can we interpolate in template

心不动则不痛 提交于 2019-12-04 03:53:43
问题 I read that we can interpolate Javascript expressions. What is the list of valid Javascript expressions that we can interpolate? So far for interpolation I have a displayed property, eg. object.property , short expressions like {{1+1}} what else Javascript expressions can we interpolate? 回答1: Expressions in Angular2 are very similar to expressions in Angular in terms of the scope of what they allow. JavaScript expressions that promote side effects are prohibited including Assignment (= +=, -=

angular 2 model driven nested form components

时间秒杀一切 提交于 2019-12-03 13:04:11
问题 What I have: I am building an ionic 2 app and have built a basic angular 2 component that contains An input field A label to display the inputs title A label to display any validation errors I will refer to this as my input component I have a page component with a form on it, and currently have text inputs. 1 regular input (password) and 1 input wrapped in my input component (username). this is the relevant portion of my page component ngOnInit() { this.loginForm = this.formBuilder.group({