Questions tagged [directive]

A concept of 'command' used by many programming languages and frameworks. Use this tag with a language and/or framework to indicate context. The C/C++ pre-processor is one language that relies heavily on directives. They call it "pragmas".

2065 questions
55
votes
2 answers

Passing array via attribute to AngularJS directive

I'm currently having a problem when passing an array to a directive via an attribute of that directive. I can read it as a String but i need it as an array so this is what i came up with but it doesn't work. Help anyone? thks in…
HeberLZ
  • 12,715
  • 4
  • 22
  • 24
51
votes
3 answers

AngularJS $watch window resize inside directive

I have revealing module pattern which looks like this: 'use strict'; angular.module('app', []) .directive('myDirective', ['SomeDep', function (SomeDep) { var linker = function (scope, element, attr) { // some work }; …
Lightfooted
  • 799
  • 1
  • 6
  • 13
47
votes
9 answers

Define AngularJS directive using TypeScript and $inject mechanism

Recently I started refactoring one of the Angular projects I am working on with TypeScript. Using TypeScript classes to define controllers is very convenient and works well with minified JavaScript files thanks to static $inject Array
Milko Lorinkov
  • 600
  • 1
  • 5
  • 8
47
votes
4 answers

Angular JS resizable div directive

My site will have multiple sections, each of which I intend to be resizable. To accomplish this I've made a "resizable" directive, e.g.:
jayflo
  • 1,105
  • 1
  • 12
  • 21
45
votes
4 answers

What are practical scenarios of *ngTemplateOutlet directive?

I was reading about *ngTemplateOutlet directive. The use of this directive is to instantiate a template dynamically by a template reference and context object as parameters. What I want to know is that we have so many things in Angular to achieve…
patrick.1729
  • 4,222
  • 2
  • 20
  • 29
42
votes
4 answers

what is the meaning of align an the start of a section?

What is the meaning of align an the start of a section? For example: align 4 a: dw 0 How does it save memory access?
user1462787
  • 659
  • 2
  • 12
  • 20
41
votes
2 answers

How to check if a method argument of a directive is specified in AngularJS?

I've created a custom directive which contains a button. This button calls a method from parent scope specified by 'callback' attribute. Simple directive
Ferenc T
  • 766
  • 1
  • 6
  • 12
41
votes
3 answers

AngularJS - Attribute directive input value change

I've got an AngularJS attribute directive, and I would like to take an action any time its parent input's value changes. Right now I'm doing it with jQuery: angular.module("myDirective", []) .directive("myDirective", function() { return { …
Mike Pateras
  • 14,715
  • 30
  • 97
  • 137
39
votes
1 answer

Angular 2 attribute directive input values are undefined and not set correctly

I have following directive (TextElementDirective), that has 4 input variables colorHex, fontFamily, fontWeight, fontStyle. I want to set an element's color and style using this directive. @Directive( { selector: "[text-element-map]", //…
D M
  • 417
  • 1
  • 5
  • 9
39
votes
3 answers

How to use the actual use of ng-Cloak directive in AngularJs?

What is the ng-cloak directive? Why do we use it?
Anil Singh
  • 4,173
  • 4
  • 41
  • 47
36
votes
6 answers

Is there a way to both check a macro is defined and it equals a certain value at the same time

I regularly use object-like preprocessor macros as boolean flags in C code to turn on and off sections of code. For example #define DEBUG_PRINT 1 And then use it like #if(DEBUG_PRINT == 1) printf("%s", "Testing"); #endif However, it comes a…
gbmhunter
  • 1,747
  • 3
  • 23
  • 24
35
votes
2 answers

What are the benefits of a directive template function in Angularjs?

According to the documentation a template can be a function which takes two parameters, an element and attributes and returns a string value representing the template. It replaces the current element with the contents of the HTML. The replacement…
33
votes
3 answers

How to get FormControl instance from ControlValueAccessor

I've the following component: @Component({ selector: 'pc-radio-button', templateUrl: './radio-button.component.html', providers: [ {provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => FieldRadioButtonComponent), multi:…
Gediminas Bublys
  • 403
  • 1
  • 4
  • 10
32
votes
7 answers

Alias 403 Forbidden with Apache

I'm trying to create a folder named week7 and an html page named hello.html in that folder outside the document root and have it viewed through an Alias directive. I created a folder named week7 out of the Document Root. I chose this location for…
Yousif
  • 355
  • 1
  • 3
  • 8
31
votes
6 answers

Understanding AngularJS ng-src

As explained here, the AngularJS directive ng-src is used to prevent the browser from loading the resource (e.g. image) before the handlebars get parsed. I'm currently using the following code:
Martijn
  • 5,491
  • 4
  • 33
  • 41