Questions tagged [angular-directive]

At a advanced stage, directives serve as distinctive indicators placed on a DOM component (e.g., attribute, element name, comment, or CSS class) to signal the Angular 2+ framework to associate specific functionality with said DOM element, or even modify both the DOM element and its offspring. This tag is dedicated solely for Angular 2+.

What is the best way to retrieve the attribute data of an element using Angular's jqlite?

How can I access an element's attribute data in angular using jqlite? html, <button ng-click="loadForm($event)" href="form.php">Load Directive Form</button> <div data-my-form></div> angular, app.directive('myForm', function ...

Could someone elaborate on the fundamental idea behind models in AngularJS?

HTML Markup: <mydirective></mydirective> <input type="button" ng-click="showText()" value="Show Service Text" /> Javascript Code: var app = angular.module('demo', []); app.service('myService', function () { ...

Adding *ngIf dynamically within a directive allows for conditional rendering based on certain parameters or

Is there a way to dynamically include an *ngIf on an element that is decorated with an attribute directive? I decided to test this with a simple experiment: @Directive({ selector: '[lhUserHasRights]' }) export class UserHasRightsDirective i ...

RxJS: Ensure Observables emit values sequentially, waiting for the completion of the previous Observable

In my current project, I have been working on implementing a unique Angular structural directive. This directive is designed to read and store the text content of an HTML element along with all its children, remove the contents upon AfterViewInit, and then ...

Tips for concealing information within the column labeled company Name with respect to the field designated as Company Name

I am currently working on an Angular 7 app and I am facing an issue: I cannot hide the data in the column for Company Name. The field "Name" in the report control JSON is labeled as Company Name. The report control is a table that contains various fields ...

Passing a function from one directive to another directive

I am facing a situation where I have two directives that are separate. If a certain condition is evaluated as true, I need to call the second directive from within the first one. myDirectives.directive('first', function() { return { restri ...

Encountering 'error: undefined' message in dropzone.js success function

I created an Angular.js directive that adds a dropzone to my app and binds a function to the success event of dropzone.js. However, I am only able to retrieve the response and the file is undefined. The response is coming from the API that uploads the file ...

Issue with Transclusion in Angular UI Modal functionality is not functioning as intended

One goal of this plunk is to transclude elements into an Angular UI Modal from a controller, with the Modal being wrapped by a directive. The objective should meet the following conditions: The directive must specify the transclusion of fields. These fie ...

Is it possible to utilize an ng template within one component and then reference its template in another HTML file?

I'm experimenting with using ng-template in a separate component and referencing it in other parts of the html. Is this possible? I've tried different approaches but seem to be missing something. Can you help me understand where I might be going ...

What is the process for configuring the directive to establish a drag-and-drop area within Angular?

I am currently working on implementing a file drag and drop zone in Angular. I have created the dropzone.directive and added it to the declarations in app.module.ts. While my code compiles and launches successfully, I am facing an issue where the HTML doe ...

Is there a way to compel Google Maps to load within my Angular application by implementing an Angular Directive?

I am encountering an issue where my Google Map fails to display most of the time. It seems that the map is not fully rendered when the rest of my data is populated in my Angular view. Is there a way to force the map to load? I have done some research and ...

Utilizing AngularJS: Dynamically employ custom directives for enhanced reusability

I am currently developing my debut single page Angular.js application and finding myself in a bit of a rut when it comes to programmatically compiling/evaluating a custom directive to insert it into the DOM from within a controller. The custom directive I ...

Is it possible to achieve pagination by simply dragging the scroll bar to the top or bottom position?

Recently, I've been working on implementing a pagination function for a list of items. The pagination currently works well with scrolling events - it automatically moves to the next page when scrolling to the bottom, and to the previous page when scrolling ...

The directive within the module was not carried out

After setting up a fresh module in my Angular 8 project and adding a new directive to it, nothing seemed to happen at runtime (although the compilation was successful). I even added console logs to the directive to check if it was being executed different ...

Challenges encountered when setting a value to a custom directive via property binding

I'm working on a question.component.html template where I render different options for a specific question. The goal is to change the background color of an option to yellow if the user selects the correct answer, and to red if they choose incorrectly ...

Issue with Ng-Messages not functioning properly due to a custom ng-Include directive lacking a child scope

I have created a custom directive called lobInclude, which is similar to ngInclude but with no isolated scope: .directive("lobInclude", ["$templateRequest", "$compile", function($templateRequest, $compile) { return { restrict: "A", ...

Implementing a onClick event to change the color of individual icons in a group using Angular

I have integrated 6 icons into my Angular application. When a user clicks on an icon, I want the color of that specific icon to change from gray to red. Additionally, when another icon is clicked, the previously selected icon should revert back to gray whi ...

The connections of directives

In my Angular application, I am encountering an issue while trying to enhance the functionality of a third-party directive with my own custom directive. The problem lies in the order of instantiation of these directives. The intended usage of the directiv ...

When considering Angular directives, which is more suitable for this scenario: structural or attribute?

In the process of developing an Angular 5 directive, I aim to incorporate various host views (generated from a component) into the viewContainer. However, I find myself at a crossroads as to whether I should opt for an attribute directive or a structural ...

Angular 10: Issue encountered while trying to instantiate an Object of an Object

export class School { constructor( public name: string, public address: Address, public district: string, public contactNumber: string, public gradeRange: string, public currentYear: number, ...

Improving user input in AngularJS

My goal is to create a filter that converts time into seconds, such as: 01:30:10 becomes 5410, and vice versa. This way, the model only holds seconds while providing users with a more user-friendly representation. I've successfully implemented a working e ...

How can I implement a recursive nested template call in Angular 2?

Hopefully the title isn't too misleading, but here's my dilemma: I am in the process of building an Angular 2 app and utilizing nested templates in multiple instances. The problem I am facing involves "widgets" within my app that can contain other widgets ...

Passing information from a directive to a controller using AngularJS

I am looking to display the progress of a file upload using a file reader. Here is the HTML code snippet I have: <md-progress-linear id="file-progress-indicator" md-mode="determinate" value="{{progress}}"></md-progress-linear> and below is m ...

Best event for Angular directive to bind on image onload

I'm currently working on incorporating this particular jQuery plugin into my Ionic application. Although I have a good grasp of creating an Angular directive to encapsulate the plugin, I am encountering difficulties in successfully implementing it. Below ...

Access the Angular directive instance before it is actually rendered

Is it possible to access an Angular directive instance even if it has not been rendered yet? Let's say I have an app-component and a baz-directive. I want to be able to get the directive instance even if it is not currently shown or rendered in the DOM. W ...

"The `ngClass` directive allows for applying classes as an `object` rather than just a simple `class` value

When applying the class name like this: <tr *ngIf="crud.isCreate" [ngClass]="{'create' : crud?.isCreate}"> The class name is not being added correctly. In HTML, it appears as: <tr _ngcontent-yql-c9="" ng-reflect-ng-class="[object Object]"> - ...

Circular Dependency Detected in Angular 7 Library: A Tight Web of Directive, Service, and Module Interconnections

After setting up a new Angular 7 project with a library that includes a directive, a service, and a module (where the directive gets the service injected and the service has an injectionToken exported in the module), I encountered these warnings during com ...

Creating an Angular Directive for Setting the Tab Index on Enter Key Press

I need assistance with firing the Tab key event on keydown.Enter in an entire form. Currently, I am running the functions on the parent Div using the following code. Although the event is detected in the console, no changes occur on the input field (i.e., ...

Execute tap() function without subscribing

Can the tap() pipe function be executed without subscribing to it? observer$:BehaviorSubject<number[]> = new BehaviorSubject<number[]>([1]) getData(page:number):void{ of(page).pipe( tap({ next: (data) => this.observe ...

When navigating using the next and back buttons, the active state in Angular is automatically removed

Looking for some assistance with my quiz app setup. Each question has True/False statements with corresponding buttons to select T or F. However, when I click the next/back button, the active class is not being removed from the previous selection. As a beg ...

Implementing a class addition on focus event using Angular 2

Currently, I am in the process of upgrading an Angular 1 application to Angular 2 and encountering an issue with one of my existing directives. The task at hand is straightforward. When an input field is focused, a class should be added (md-input-focus) a ...

Dynamically render a nested component, created within the parent component, using a directive

Can a nested component be dynamically rendered as a directive within the parent component? Instead of using the standard approach like this: <svg> <svg:g skick-back-drop-item /> </svg> where "skick-back-drop-item" is the s ...

Developing a specialized directive to enhance bootstrap menuItems

I have created a custom directive in AngularJS for the navbar in Bootstrap. This directive uses ng-transclude and handles two types of list items (li) depending on whether it is a dropdown or not. However, I am experiencing issues with the dropdown functio ...

Manipulating the DOM with AngularJS directives is not functioning as expected

I am facing an issue with integrating a code that needs to scroll slowly on the page using AngularJS 1.4. When I try to include this code in a directive using the link function(scope, element, attrs), it doesn't work properly. Interestingly, the code ...

What are the recommended tools for translating in Angular 2 - pipes or directives?

Currently in search of a solution that allows me to create my own translations to replace the translated text. I am trying to determine whether utilizing Pipes or Directives would be more advantageous in terms of performance, especially considering the lar ...

Creating a unique syntax for custom ngIf directives in Angular

Currently, I am in the process of developing a personalized *ngIf directive that will swap out content with a placeholder during loading. After referencing the *ngIf directive (https://github.com/angular/angular/blob/master/packages/common/src/directives/n ...

Incorporating HTML with ng-binds through transclusion

I have been developing an angular directive to enhance the functionality of ng-table by adding filtering and exporting features. The main goal is to make this directive reusable for multiple tables, which requires the <td> elements to be dynamic. To ...

Angular 11 Working with template-driven model within a directive

My currency directive in Angular 8.2 formats currency fields for users by using the following code: <input [(ngModel)]="currentEmployment.monthlyIncome" currency> @Directive({ selector: '[ngModel][currency]', providers: [Curr ...

Is requesting transclusion in an Angular directive necessary?

An issue has cropped up below and I'm struggling to figure out the reason behind it. Any suggestions? html, <button ng-click="loadForm()">Load Directive Form</button> <div data-my-form></div> angular, app.directive('myForm', ...