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".

1990 questions
364
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
  • 11,238
  • 25
  • 93
  • 155
296
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
  • 11,822
  • 13
  • 57
  • 94
295
votes
40 answers

Getting "type or namespace name could not be found" but everything seems ok?

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
  • 31,898
  • 75
  • 232
  • 424
249
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,042
  • 10
  • 26
  • 35
162
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,735
  • 3
  • 13
  • 11
117
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
  • 38,727
  • 46
  • 165
  • 296
99
votes
5 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,123
  • 1
  • 7
  • 14
88
votes
4 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
  • 107,550
  • 65
  • 332
  • 414
68
votes
7 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
  • 34,999
  • 4
  • 21
  • 21
66
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,538
  • 7
  • 26
  • 41
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,630
  • 7
  • 41
  • 70
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,480
  • 7
  • 20
  • 30
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
  • 8,576
  • 4
  • 20
  • 24
51
votes
5 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
  • 1,957
  • 5
  • 21
  • 35
50
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
  • 769
  • 1
  • 6
  • 13
1
2 3
99 100