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
16
votes
3 answers

angular ng-repeat expressions as variables

I'm trying to do something like this:
  • {{row.name}}
But because the ng-repeat logic is in the compile state of the directive it treats the {{myRepeatExpression}} as a normal string instead…
Gilad
  • 339
  • 1
  • 4
  • 14
15
votes
2 answers

Should I use [innerHTML] or the usual way (Angular 2)

I have my example: string; in my component.ts file. I can output this variable in two ways (at least that I know of): I can do:

{{ example }}

and I can do:

Well, when I use the first way, my IDE (phpStorm)…
Eliya Cohen
  • 10,716
  • 13
  • 59
  • 116
15
votes
2 answers

Angular Directive attrs.$observe

I found this Angular Directive online to add a twitter share button. It all seems staright forward but I can't work out what the attrs.$observe is actually doing. I have looked in the docs but can't see $observe referenced anywhere. The directive…
ttmt
  • 5,822
  • 27
  • 106
  • 158
15
votes
1 answer

Controller 'ngModel', required by directive '…', can't be found

What's going on here? Here are my directives: // template app.directive('bseInput', function () { return { templateUrl: "/Scripts/bse/bse-inputs.html", scope: { theModel: '=', …
Shaun Luttin
  • 133,272
  • 81
  • 405
  • 467
15
votes
2 answers

Angular testing using passThrough in unit testing

I'm trying to test a Directive in Angular, but I can't get the corresponding template to work. The directive lists the templateUrl like so templateUrl: 'directives/listview/view.html' Now when I write any unit-test, I get Error: Unexpected request:…
Willem Mulder
  • 12,974
  • 3
  • 37
  • 62
15
votes
2 answers

Set templateUrl base on attribute in directive

I'm working on a set of angular directives and I want to load the correct template based on the presence or value of an attribute. If horizontal, templateUrl should be…
ritcoder
  • 3,274
  • 10
  • 42
  • 62
14
votes
6 answers

AngularJS - How to modularize a directive + template combination?

Here's the situation. I have a directive, that depends on a templateUrl. The directive looks something like this: angular.module('foo') .directive('bar', function(){ return { restrict: 'E', replace: true, templateUrl: '/foo/bar.html', …
bioball
  • 1,339
  • 1
  • 12
  • 23
14
votes
4 answers

Difference between .equ and .word in ARM Assembly?

I am curious - What is the difference between .equ and .word directives in ARM assembly, when defining constants?
jhtong
  • 1,529
  • 4
  • 23
  • 34
13
votes
1 answer

What is the difference between component and directive in Angular 2?

I've been struggling to understand what is the difference between these two concepts in the framework. I'm well familiar with what directives in AngularJS 1.x are and both components and directives in Angular 2 seems quite similar to this concept...
Josh Long
  • 185
  • 1
  • 7
13
votes
2 answers

Angular: Bind callback function using & and pass-in arguments

I have a (simplified) directive angular.module('myApp') .directive('myButton', function () { return { restrict: 'E', scope: { callbackFn: '&' }, template: '
Jeanluca Scaljeri
  • 26,343
  • 56
  • 205
  • 333
13
votes
1 answer

Angular directive with ng-repeat, ng-show "Show more" and lazy-load

I use this directive, iterating over an array "myArr", filtering for a few conditions.
chrney_p
  • 165
  • 1
  • 2
  • 7
12
votes
3 answers

ANGULAR 4 Base64 Upload Component

I am new to Angular. I am using Angular 4. Where there is a requirement to send the base64 Image as one of the model member to the web api. Is there a Angular component or directive for the that would bind the base64 to the said model? Appreciate…
Vijayavel
  • 123
  • 1
  • 1
  • 5
12
votes
6 answers

Double Tap/ double click Angular2 & ionic

I am searching on many forums and questions, but nobody seems to ask how to double click ou double tap in Angular/ionic 2 ? In ionic v1 it was available with on-double-tap (see http://ionicframework.com/docs/api/directive/onDoubleTap/) Does anyone…
luiswill
  • 952
  • 1
  • 11
  • 21
12
votes
3 answers

Angular2 keyup event update ngModel cursor position jumps to end

I am having an issue with an Angular2 directive that should do the following: Detect if the user enters '.' character. If the next char is also '.', remove the duplicate '.' and move the cursor position to after the '.' char I have the above…
conor
  • 883
  • 5
  • 14
  • 25
12
votes
3 answers

How to add validation attributes in an angularjs directive

I am trying to write an angular directive that adds validation attributes to the tag, but it doesn't seem to be working. Here is my demo. You will notice that "Is Valid" remains true if you delete the text in the second input box, but goes to…
Leslie Hanks
  • 2,347
  • 3
  • 31
  • 42