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".
Questions tagged [directive]
2065 questions
12
votes
4 answers
Pass parameters from directive to callback
I'm trying to define a directive sortable which wraps jqueryui's sortable plugin.
The angular code is:
module.directive('sortable', function () {
return function (scope, element, attrs) {
var startIndex, endIndex;
…

Freewind
- 193,756
- 157
- 432
- 708
11
votes
1 answer
Is it possible to upgrade angularjs atttribute directives to use in angular 4?
I've been able to upgrade an angularjs element directive to be used in angular 4.
Here's a sample code:
[myScores.js]
angular.module('app.components.directives.myScores', [])
.directive('myScores', function() {
return {
scope: {
score:…

Will
- 1,718
- 3
- 15
- 23
11
votes
1 answer
What's the difference between the .asciz and the .string assembler directives?
I know that the .ascii directive doesn't put a null character at the end of the string, as the .asciz directive is used for that purpose. However, I don't know whether the .string directive puts a null character at the end of the string.
If it does…

Aadit M Shah
- 72,912
- 30
- 168
- 299
11
votes
1 answer
angular directive handles http request
I have angular directive that accept url to obtain remote data:
...
Directive itself:
app.directive('myTag', ['$http', function($http) {
return {
restrict: 'E',
transclude: true,
replace: true,
…

Dewfy
- 23,277
- 13
- 73
- 121
11
votes
2 answers
Getter & setter support with ng-model in AngularJs
I am trying to get getter/setter support for ng-model by implementing a directive that will take care of getting and setting the values to/from the view/model. I am almost there, but I end up in infinite $digest loops.
The idea is to set…

sboisse
- 4,860
- 3
- 37
- 48
11
votes
1 answer
Conditional outer tag in a directive (i.e. )
I like a directive that conditionally puts a tag outside some content (but always prints the content), like this:
{{model.text}}/p> so if condition is true I get
yada…

joeriks
- 3,382
- 8
- 32
- 42
11
votes
2 answers
Using ng-hide or ng-show on select box option
Is it possible to hide select box options using the ng-hide directive?
http://jsfiddle.net/cr4UB/
11
votes
4 answers
AngularJS Typescript Directive
Having problems creating nested directive using Typescript. I can do it in simple AngularJs:
http://plnkr.co/edit/UruTqEdMnqNT5wjxcQNC?p=preview ,
but using TypeScript it gives me "No controller" error message.
///

Algimantas Krasauskas
- 403
- 1
- 5
- 19
11
votes
1 answer
AngularJS - Formatting ng-model before template is rendered in custom directive
I am creating a custom directive in Angular JS. And I want to format the ng-model before the template renders.
This is what I have so far:
app.js
app.directive('editInPlace', function() {
return {
require: 'ngModel',
restrict:…

Lulu
- 231
- 1
- 4
- 7
11
votes
3 answers
Specifying an online image in Sphinx (restructuredtext) format
Any ideas on how I can refer to an online image while documenting with Sphinx?
This does NOT work:
.. image:: http://www.mysite.com/images/someimage.png
Gives me:
/home/user/proj/2010/11/08/the_forever_war.rst:11: WARNING: nonlocal image URI found:…

stratosgear
- 942
- 1
- 16
- 37
10
votes
3 answers
Angular 4 Directive selector to target an element inside a component only
How to target a specific element inside a component in Angular Directive.
I have a component with selector "highlighter". This component has content project using ng-content.
There is a directive with selector "highlighter input".
I believe this…

Suresh Nagar
- 1,021
- 9
- 20
10
votes
1 answer
AngularJS - $compile a Directive with an Object as an Attribute Parameter
When I use $compile to create and bind a directive, how can I also add a variable as an attribute? The variable is an object.
var data = {
name: 'Fred'
};
var dirCode = ' ';
var el =…

kenshin9
- 2,215
- 4
- 23
- 38
10
votes
1 answer
AngularJS directive: template with scope value (ng-bind-html)
I have such directive:
...
template: function(element, attrs) {
var htmlTemplate = '
\
\
';
return…
brabertaser19
- 5,678
- 16
- 78
- 184
10
votes
2 answers
Using @import in objective C in conjunction with __cplusplus
When I try to compile an Objective C++ file (.mm) that is linked to a file that uses the new @import directive, I get some errors. Currently, my only solution is to replace the @import with the old #import directive.
Is there any other solution so…

Mihai Popa
- 892
- 1
- 8
- 25
10
votes
2 answers
AngularJS input ng-model not updating
I am trying to create a simple pagination directive with an isolated scope. For some reason when I manually change the value it gets a bit finnicky. Here is my problem:
When I page forward and backward, it works great. Awesome
When I enter a page…

user1200387
- 625
- 2
- 13
- 22