Search Posts

Category: angular2-directives

*ngIf Angular directive

I need to move a project out of angular, and thus need to change many of the directives i’ve been using. I was wondering if anyone knew what I could change the *ngIf directive to in plain javascript? example: <li *ngIf=”currentLanguage !== ‘en'”><a onClick=”changeLanguage(‘en’) “hreflang=”en”><img class=”flag” src=”assets/languages/en.png” alt=””>{{‘NAVIGATION_EN’|translate}}</a></li> Source: AngularJS

ngClass does not update DOM in Promise Callback

I have a Rating Component (Angular) as follows: import { Component, ChangeDetectionStrategy, Input, NgZone, ApplicationRef} from ‘@angular/core’; import { Icon } from ‘ionic-angular/components/icon/icon’; import { Events } from ‘ionic-angular’; // import { ImageService } from ‘../../providers/image-service/image-service’; // @Component({ selector: ‘rating’, providers: [Icon], templateUrl: ‘rating.html’, changeDetection: ChangeDetectionStrategy.OnPush }) export class RatingComponent { static readonly RATING_CHANGE: string = ‘ratings-changed’; text: string; private tempscore: number = 0; // @Input() public score: number = 0; @Input() public max: number […]

custom directive not working in future element in angular4

I have made a custom directive in angular 4 and it is using in future html element. But its not working. Below are code example. HTML added in future. (removeTag is attribute) var html = ‘<span _ngcontent-c3 removeTag class=”tag-r”>’; html += ‘<input type=”hidden” name=”con_tags[]” value=”‘ + txt + ‘” />’; html += txt + ‘</span>’; this.elRef.nativeElement.insertAdjacentHTML(‘beforebegin’, html); removeTag Directive code @Directive({ selector: ‘[removeTag]’ }) export class removeTagDirective { constructor( private elRef: ElementRef, private renderer: Renderer2) […]

Angular 2 ag-grid’s Clear Filter button clears the textbox without refreshing column when built-in filter is used

When ag-grid’s default filter is enabled, the clear filter button only clears the text box and doesn’t refresh the column even though ‘clearButton’ and ‘applyButton’ params are set to true. After clicking the Clear filter button the text gets cleared from the textbox and I have to actually click Apply Filter button to remove the filter and refresh the column. Below is my code: result.filter = “date”; result.filterParams = { applyButton: true, clearButton: true }; […]

How to use value of click function of addEventListener in another function?

I want to use value of a click function in another function using angular 2. My code is written below : optionFn(id){ let root = this.viewCtrl.instance.navCtrl._app._appRoot; // console.log(root); document.addEventListener(‘click’, function (event) { let btn = document.querySelector(‘.remove-ok .alert-button-default:nth-child(2)’); let target = event.target; if (btn && target.className == ‘alert-radio-label’) { let view = root._overlayPortal._views[0]; let inputs = view.instance.d.inputs; console.log(“inputs” + JSON.stringify(inputs)); for(let input of inputs) { let input = inputs_1[_i]; if (input.checked) { // this.optionEvent1 =input.value; view.instance.d.buttons[1].handler([input.value]); […]

Angular 2, Using Jquery to Manipulate Bootstrap

I’m pretty new with NG2, and I’m trying to add Slide Up/Down effects do default Bootstrap 4 Dropdown component. The Bootstrap dropdown component has 2 Jquery Listeners $(el).on(‘show.bs.dropdown’) and $(el).on(‘hide.bs.dropdown’). So I created a directive to add this effects: import { Directive, OnInit, AfterViewChecked, ElementRef, Input } from ‘@angular/core’; import * as $ from ‘jquery’; @Directive({ selector: ‘[appDropDownAnimate]’ }) export class DropDownAnimateDirective implements AfterViewChecked { @Input() appDropDownAnimate: boolean; private el = this.ElementRef.nativeElement; constructor(private ElementRef: ElementRef) […]