angular2-directives

Cannot read property 'nativeElement' of undefined - ngAfterViewInit

有些话、适合烂在心里 提交于 2019-11-30 23:38:55
I'm trying to add a "clipboard" directive using this example . The example is now outdated so I have had to update how it is getting the nativeElement. I'm getting the error Cannot read property 'nativeElement' of undefined I have marked the error in the code with <===== error here: clipboard.directive.js import {Directive,ElementRef,Input,Output,EventEmitter, ViewChild, AfterViewInit} from "@angular/core"; import Clipboard from "clipboard"; @Directive({ selector: "[clipboard]" }) export class ClipboardDirective implements AfterViewInit { clipboard: Clipboard; @Input("clipboard") elt

Adding a Component to a TemplateRef using a structural Directive

心已入冬 提交于 2019-11-30 20:21:57
We are building an angular 4 component library and one of the components is a Busy component. The purpose of the component is to allow a developer to create an overlay on any given HTML element which contains a spinner graphic. <div *xuiBusy="isBusy">...</div> When the value of isBusy is true we want to append to the inner content of the div so that we can present the overlay elements on top of the content. We have been able to append the component to the ViewContainerRef however this inserts the busy element as a sibling to the div rather than within the div as desired. ngOnInit(): void {

Cannot read property 'nativeElement' of undefined - ngAfterViewInit

自闭症网瘾萝莉.ら 提交于 2019-11-30 18:57:46
问题 I'm trying to add a "clipboard" directive using this example. The example is now outdated so I have had to update how it is getting the nativeElement. I'm getting the error Cannot read property 'nativeElement' of undefined I have marked the error in the code with <===== error here: clipboard.directive.js import {Directive,ElementRef,Input,Output,EventEmitter, ViewChild, AfterViewInit} from "@angular/core"; import Clipboard from "clipboard"; @Directive({ selector: "[clipboard]" }) export class

Uncaught exception in promise when when trying to use nested components

≯℡__Kan透↙ 提交于 2019-11-30 17:07:00
I am getting this exception when trying to use nested components: EXCEPTION: Error: Uncaught (in promise): TypeError: Cannot set property 'endSourceSpan' of null XCEPTION: Error: Uncaught (in promise): TypeError: Cannot set property 'endSourceSpan' of nullBrowserDomAdapter.logError @ angular2.dev.js:23877BrowserDomAdapter.logGroup @ angular2.dev.js:23888ExceptionHandler.call @ angular2.dev.js:1317(anonymous function) @ angular2.dev.js:12763schedulerFn @ angular2.dev.js:13167SafeSubscriber.__tryOrUnsub @ Rx.js:10775SafeSubscriber.next @ Rx.js:10730Subscriber._next @ Rx.js:10690Subscriber.next @

Multiple child component inside form - Angular 2

試著忘記壹切 提交于 2019-11-30 16:08:28
I am working on big form, so i plan to truncate the form into multiple child components which helps for easy integration and maitainbility. Using form builder i am trying to implement this. mainform.html <form novalidate (ngSubmit)="onSubmit(formDetail);" [formGroup]="formDetail"> <label> <span>Name</span> <input type="text" placeholder="Enter emp name" formControlName="name"> </label> <app-userinfo></app-userinfo> <!-- Child component 1 --> <app-useracc></app-useracc> <!-- Child component 2 --> </form> mainform.ts export class MainformComponent implements OnInit { formDetail: FormGroup;

How to utilize jqGrid in Angular 2+?

瘦欲@ 提交于 2019-11-30 15:44:15
In my current project we have been using jqGrid in almost every page. We use the grid's full rich featureset including complex grid inline row editing, with drop down, check box and other controls, sorting, column filtering and more. Now we wish to convert our project into angular 2, but our main problem is replacing jqGrid's rich featureset. Before starting I need to do some POC if all the functionalities can be done in angular 2 based grid. How can jqGrid be used in Angular 2+? You don't wrote which version of jqGrid you use and from which fork of jqGrid. The development is spitted after

How to migrate Angular 2 RC 1 (or earlier) Forms to Angular 2 RC 2 / RC 4 New Forms

爷,独闯天下 提交于 2019-11-30 14:04:17
I need to migrate my existing Angular 2 RC 1 app to Angular 2 RC 4. As a part of which I also need to move my existing forms to Angular 2 RC 4 New Forms. Can anyone please guide, how to update existing forms to new form. For those who are having trouble in migrating forms from Angular 2 RC 1 (or earlier) to Angular 2 RC 2 / RC 4 New Forms. Here are the steps they need to follow: Include new forms in your project by adding below package to their packages.json: "@angular/forms": "0.2.0", Next, they have to disable the deprecated forms in main file and include new forms something like below:

How to Unit Test a Directive In Angular 2?

岁酱吖の 提交于 2019-11-30 12:43:16
问题 Problem: I would like to be able to unit test a directive in Angular 2 to make sure that it properly compiles. In Angular 1, it was possible to use $compile(angular.element(myElement) service and call $scope.$digest() after that. I specifically want to be able to do this in unit tests so I could test that when Angular ends up running across <div my-attr-directive/> in the code that my-attr-directive compiles. Constraints: Angular 2 using JAVASCRIPT . All sources somewhat related seem to

Angular 2 Directive implementing ControlValueAccessor doesn't update 'touched' property on change

本秂侑毒 提交于 2019-11-30 12:42:09
I'm trying to create my own Angular 2 Directive for Jquery UI Datepicker. I've seen some different approaches on the internet and in SO as well, but no one achieves the goal that I want to. So this is the code that I have so far: import {Directive, ElementRef, Input, forwardRef} from '@angular/core'; import {ControlValueAccessor, NG_VALUE_ACCESSOR} from "@angular/forms"; declare var $:any; @Directive({ selector: '[date-picker]', providers: [{ provide: NG_VALUE_ACCESSOR,useExisting: forwardRef(() => DatePickerDirective), multi: true }] }) export class DatePickerDirective implements

How to Include moment-timezone in Angular 2 App

感情迁移 提交于 2019-11-30 11:31:10
I realize, this question is repeated but previous once does not provide apt answer moment package was already installed 1.Installed package npm install moment-timezone --save Inside node_modules directory | |--moment |--moment-timezone directories present 2. Index.html included script <script src="node_modules/moment-timezone/moment-timezone.js"></script> System.config.js var map = { 'moment': 'node_modules/moment', 'momentzone': 'node_modules/moment-timezone' }; var packages = { 'moment': { defaultExtension: 'js' }, 'momentzone': { defaultExtension: 'js' } }; 3.Inside component.ts file import