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
365
votes
5 answers

How to get evaluated attributes inside a custom directive

I'm trying to get an evaluated attribute from my custom directive, but I can't find the right way of doing it. I've created this jsFiddle to elaborate.
Shlomi Schwartz
  • 8,693
  • 29
  • 109
  • 186
333
votes
47 answers

How do I fix a "type or namespace name could not be found" error in Visual Studio?

I'm getting a: type or namespace name could not be found error for a C# WPF app in VS2010. This area of code was compiling fine, but suddenly I'm getting this error. I've tried removing the Project Reference and the using statement, shutting…
Greg
  • 34,042
  • 79
  • 253
  • 454
298
votes
8 answers

AngularJS - Create a directive that uses ng-model

I am trying to create a directive that would create an input field with the same ng-model as the element that creates the directive. Here's what I came up with so far: HTML
kolrie
  • 12,562
  • 14
  • 64
  • 98
251
votes
10 answers

Calling a function when ng-repeat has finished

What I am trying to implement is basically a "on ng repeat finished rendering" handler. I am able to detect when it is done but I can't figure out how to trigger a function from it. Check the fiddle:http://jsfiddle.net/paulocoelho/BsMqq/3/ JS var…
PCoelho
  • 7,850
  • 11
  • 31
  • 36
164
votes
12 answers

Update Angular model after setting input value with jQuery

I have this simple scenario: Input element which value is changed by jQuery's val() method. I am trying to update the angular model with the value that jQuery set. I tried to write a simple directive, but it's not doing what I want. Here's the…
Michal J.
  • 1,765
  • 3
  • 14
  • 11
132
votes
6 answers

Angular2 Can't bind to DIRECTIVE since it isn't a known property of element

I generated new @Directive by Angular CLI, it was imported it to my app.module.ts import { ContenteditableModelDirective } from './directives/contenteditable-model.directive'; import { ChatWindowComponent } from…
Tomas Javurek
  • 1,493
  • 2
  • 9
  • 16
119
votes
5 answers

How do I pass multiple attributes into an Angular.js attribute directive?

I have an attribute directive restricted as follows: restrict: "A" I need to pass in two attributes; a number and a function/callback, accessing them within the directive using the attrs object. If the directive was an element directive,…
Undistraction
  • 42,754
  • 56
  • 195
  • 331
89
votes
5 answers

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

What's going on here? Here is my directive: app.directive('submitRequired', function (objSvc) { return { require: 'ngModel', link: function (scope, elm, attrs, ctrl) { // do something } }; }); Here is an…
Shaun Luttin
  • 133,272
  • 81
  • 405
  • 467
78
votes
9 answers

How would you do the equivalent of preprocessor directives in Python?

Is there a way to do the following preprocessor directives in Python? #if DEBUG < do some code > #else < do some other code > #endif
intrepion
  • 38,099
  • 4
  • 24
  • 21
70
votes
6 answers

Angularjs - Pass argument to directive

Im wondering if there is a way to pass an argument to a directive? What I want to do is append a directive from the controller like this: $scope.title = "title"; $scope.title2 =…
SKYnine
  • 2,708
  • 7
  • 31
  • 41
61
votes
7 answers

What does ORG Assembly Instruction do?

can anyone give me a comprehensive description about ORG directive? When and why is it used in assembly written applications? Using Nasm on x86 or AMD64.
sepisoad
  • 2,201
  • 5
  • 26
  • 37
61
votes
5 answers

AngularJS : What is the best way to bind to a global event in a directive

Imagine the situation in AngularJS where you want to create a directive that needs to respond to a global event. In this case, let's say, the window resize event. What is the best approach for this? The way I see it, we have two options: 1. Let…
Bas Slagter
  • 9,831
  • 7
  • 47
  • 78
61
votes
5 answers

Angularjs autocomplete from $http

I'm trying to write an autocomplete directive that fetches data from the server using an $http request (without using any external plugins or scripts). Currently it works only with static data. Now, I know that I need to insert my $http request into…
Gidon
  • 3,490
  • 7
  • 23
  • 31
60
votes
3 answers

How to use Angular structural directive with multiple inputs

I want to implement something similar with angular-permisssion. And with requirement to control the element's existance, I need to use angular structural directive. At the beginning, i think such syntax would work:

e-cloud
  • 4,331
  • 1
  • 23
  • 37

56
votes
13 answers

Check if variable exist in laravel's blade directive

I'm trying to create blade directive which echo variable (if variable defined) or echo "no data" if variable undefined. This is my code in AppServiceProvider.php:
pupadupa
  • 1,530
  • 2
  • 17
  • 29
1
2 3
99 100