angular-components

How to persist service data after reload in angular 5

爷,独闯天下 提交于 2020-07-18 14:28:49
问题 I have a service to pass data between components and when called it works but when i reload the service data gets reset.So when i searched on reload the memory is reset so is there a way to persist data even after reload without using any client side storage ? One thing i am curious is that can i achieve this using rxjs but i am not sure how this would help ?I fear to use localstorage because the data will be mostly objects or array and not user id or session id.Any inputs on this would be

How to persist service data after reload in angular 5

血红的双手。 提交于 2020-07-18 14:28:13
问题 I have a service to pass data between components and when called it works but when i reload the service data gets reset.So when i searched on reload the memory is reset so is there a way to persist data even after reload without using any client side storage ? One thing i am curious is that can i achieve this using rxjs but i am not sure how this would help ?I fear to use localstorage because the data will be mostly objects or array and not user id or session id.Any inputs on this would be

Why other components not showing up on index.html without <app-root>?

孤者浪人 提交于 2020-07-07 05:20:15
问题 I have just started learning Angular and working through some tutorials. My project is generated by Angular CLI. I have generated a new component called navbar on top of the component that was generated when I created the project and I was trying to see if navbar loads up on my index.html upon start up. My navbar shows up only when I have both app in the index.html file, for example: <body> <app-root></app-root> <app-navbar></app-navbar> </body> If I remove app-root from index.html like so:

Angular 1.5 Components difference between $onDestroy & $scope.$destroy()

时光总嘲笑我的痴心妄想 提交于 2020-06-23 04:21:48
问题 I'm trying to understand the difference between the controller's $onDestroy method and $scope.$destroy() . Definition says that $onDestroy is called when the containing scope of the component needs to be destroyed. But isn't it the same case with $scope.$destroy()? As per the plunker I've created at https://plnkr.co/edit/9RlS8OLxAoyK80WPMJaN?p=preview , <div ng-controller="ParentController"> <button ng-click="func()">Parent</button> <br><br> <div ng-controller="ChildController"> <button ng

Angular 1.5 Components difference between $onDestroy & $scope.$destroy()

本小妞迷上赌 提交于 2020-06-23 04:21:20
问题 I'm trying to understand the difference between the controller's $onDestroy method and $scope.$destroy() . Definition says that $onDestroy is called when the containing scope of the component needs to be destroyed. But isn't it the same case with $scope.$destroy()? As per the plunker I've created at https://plnkr.co/edit/9RlS8OLxAoyK80WPMJaN?p=preview , <div ng-controller="ParentController"> <button ng-click="func()">Parent</button> <br><br> <div ng-controller="ChildController"> <button ng

Angular 1.5 Components difference between $onDestroy & $scope.$destroy()

拜拜、爱过 提交于 2020-06-23 04:21:06
问题 I'm trying to understand the difference between the controller's $onDestroy method and $scope.$destroy() . Definition says that $onDestroy is called when the containing scope of the component needs to be destroyed. But isn't it the same case with $scope.$destroy()? As per the plunker I've created at https://plnkr.co/edit/9RlS8OLxAoyK80WPMJaN?p=preview , <div ng-controller="ParentController"> <button ng-click="func()">Parent</button> <br><br> <div ng-controller="ChildController"> <button ng

Property 'xxxx' does not exist on type '{ [key: string]: AbstractControl; }'

本小妞迷上赌 提交于 2020-06-18 10:27:51
问题 import { FormGroup } from '@angular/forms'; export class MasterVendorFormContactComponent implements OnInit { @Input() formContactGroup: FormGroup; // rest of the code } <fieldset [formGroup]="formContactGroup" class="master-vendor-form-contact"> <md-input-container class="master-vendor-form-contact__phone" [dividerColor]="formContactGroup.controls.phone?.valid ? 'default' : 'warn'"> <input mdInput placeholder="Enter phone" formControlName="phone"> <md-hint align="end" *ngIf="

Property 'xxxx' does not exist on type '{ [key: string]: AbstractControl; }'

眉间皱痕 提交于 2020-06-18 10:27:13
问题 import { FormGroup } from '@angular/forms'; export class MasterVendorFormContactComponent implements OnInit { @Input() formContactGroup: FormGroup; // rest of the code } <fieldset [formGroup]="formContactGroup" class="master-vendor-form-contact"> <md-input-container class="master-vendor-form-contact__phone" [dividerColor]="formContactGroup.controls.phone?.valid ? 'default' : 'warn'"> <input mdInput placeholder="Enter phone" formControlName="phone"> <md-hint align="end" *ngIf="

Property 'xxxx' does not exist on type '{ [key: string]: AbstractControl; }'

蹲街弑〆低调 提交于 2020-06-18 10:27:01
问题 import { FormGroup } from '@angular/forms'; export class MasterVendorFormContactComponent implements OnInit { @Input() formContactGroup: FormGroup; // rest of the code } <fieldset [formGroup]="formContactGroup" class="master-vendor-form-contact"> <md-input-container class="master-vendor-form-contact__phone" [dividerColor]="formContactGroup.controls.phone?.valid ? 'default' : 'warn'"> <input mdInput placeholder="Enter phone" formControlName="phone"> <md-hint align="end" *ngIf="

Does ViewContainerRef.clear() remove component from memory?

拟墨画扇 提交于 2020-05-26 04:04:42
问题 When I create a component using ViewContainerRef and assign instance to a property of parent component, which is responsible for child component creation, do I need to set this property to null after I call ViewContainerRef.clear() if I want memory to be freed? 回答1: No, if you assign parent component property to componentRef angular won't remove component from memory. Angular only destroys component and removes its own references to this component. But reference to componentRef remains to