In AngularJS directives are a way to teach HTML new tricks by extending the HTML vocabulary. Directives allow you to manage DOM elements in a declarative pattern, freeing you from low level DOM manipulation tasks.

learn more… | top users | synonyms

0
votes
0answers
11 views

Angularjs directives without html in the code?

I'm learning AngularJS and I have a bit of a problem with directives. I don't like how they look. Specifically, I don't like when there is a lot of html in the middle of the javascript. Look at the ...
0
votes
2answers
24 views

Why doesn't my $scope reflect my controller being initialized?

Question: Why is {{ name }} resulting in blank? Plunker: http://plnkr.co/edit/32t8u4VL9BiuhHcC80LF?p=preview Script: var app = angular.module('app', []); app.controller('MainCtrl', ...
0
votes
1answer
14 views

AngularStrap tooltip disables my custom directive

I am trying to get the bs-tooltip AngularStrap directive to work with my own custom directive called "checkStrength" which checks the strength of a password. When using either of these directives ...
2
votes
1answer
17 views

Initialize Zurb Foundation 5 in an AngularJS Directive

I've created three plunkrs to illustrate my problem. I'm trying to create an AngularJS Directive that will initialize foundation and apply the necessary javascript to the loaded template. At first I ...
1
vote
1answer
14 views

angular directive encapsulating a delay for ng-change

I have a search input field with a requery function bound to the ng-change. <input ng-model="search" ng-change="updateSearch()"> However this fires too quickly on every character. So I ...
0
votes
2answers
27 views

Do I NEED to supply a template for an Angular directive to wrap content?

I think I might be trying to fit a square peg into a round hole here. What I want to do is to define a convention for attaching some generic JavaScript functionality to a particular HTML attribute. ...
1
vote
2answers
25 views

Change the label for an optiongroup created with ng-options

I want to display a HTML select element with optiongroups by using the angularjs select directive. However I would like to control the value of the optgroup label attribute (every label should be ...
0
votes
1answer
9 views

Get the bounding rect for an element outside of a directive

Inside a directive I want to get the result of getBoundingClientRect() for a DOM element that is no where near the element of the directive. How should I go about this? Service that just returns that ...
0
votes
1answer
23 views

How to only listen once on $document from inside directive

I have an angular directive that needs to listen for click events on $document. Let's call it clickDirective. The click listener is added inside its link function. The problem is that if there are ...
2
votes
0answers
115 views

React compared to Angular directive with isolate scope

I have read Facebook and Instagram engineers saying that React itself lack of infrastructure to build a big project, it is only the V in MVC. Instagram seems to use it with some Backbone code for ...
0
votes
3answers
18 views

ng-app V/S data-ng-app in AngularJS

In AngularJS when using ng-app: ng-app found in the document will be used to define the root element to auto-bootstrap as an application. In some of the application it is being used as data-ng-app. ...
0
votes
1answer
20 views

AngularJs ng-if function call from same controller not working

<div ng-repeat=" x in z"> <div ng-if="function(x).y" > display this </div> </div> In the above code, ng-if function(x) is not getting called without ...
0
votes
1answer
22 views

angularJS: watch async data in directive

I'm trying to watch a async data in my directive, here is my JS code: (function(angular) { var myApp = angular.module('testTree', []); myApp.config(function($httpProvider) { ...
0
votes
1answer
11 views

How to use relative paths for images while maintaining a directory structure in angular JS?

I am using angularJS for implementation. I have created a directory structure for my application so that html pages and js will be identified. I have created a header.html which contains only header ...
0
votes
0answers
24 views

ng-show directive - inconsistent behavior

I'm trying to implement a versioning system for my application and I've tied one of the DOM elements that display the versions to the ng-show directive. <a href="#" onclick="return false;" ...
0
votes
1answer
37 views

Bootstrap popover directive and nested element with Angularjs

I've been trying to create a directive which I can arbitrarily add to an existing form (as attribute), which makes the form become a popover upon clicking on a nearby trigger link. I've got the ...
0
votes
0answers
7 views

AngularJS best practice for a directive to create a google map [migrated]

I have a considerably large directive which is doing many things: First it renders a Google Map, then it adds a listener to check when the bounds of the map change, then it renders points on the map ...
1
vote
2answers
44 views

Automatically pass $event with ng-click?

I know that I can get access to the click event from ng-click if I pass in the $event object like so: <button ng-click="myFunction($event)">Give me the $event</button> function ...
0
votes
2answers
22 views

Require directive on template

I am using RequireJS in my Angular app. I would like to require my pill where it is actualy used. pill.js define([], function() { angular.module('app').directive('pill', function() { ...
0
votes
1answer
25 views

How to replace the element with ng-transclude

Is it possible to replace the element with ng-transclude on it rather than the entire template element? HTML: <div my-transcluded-directive> <div>{{someData}}</div> ...
-1
votes
1answer
27 views

pass the values as a parameter to the ng click function

Hello take a look at sample code which is bind in html using ng-bind html directive. var _test = new Object(); <div ng-click="myFunc()"></div> I am able to get click successfully also. ...
1
vote
2answers
26 views

What is the main use of transclusion in angularjs

I have recently come across transclusion in directives, what is the purpose of having this concept. As far as I know its encapsulation of an object and have 2-way binding possibly. But this can be ...
0
votes
2answers
22 views

angularjs ui-date to show month year only

I am using ui-date directive (https://github.com/angular-ui/ui-date). This UI Calendar component is getting Date by default. Can I get only month and year without dates. How to get only month and ...
-1
votes
0answers
27 views

How maping is done at compile time in AngularJS? [on hold]

I have controller with method written in it $scope.menuClick = function () { //some code }; Then this controller is assigned to directive. But I never called this method directly in my code. I ...
0
votes
0answers
27 views

Why ngModel.$render is not getting invoked?

EDIT 1: Fixed a bug, but still not working. element.val(ngModel.$viewValue || ''); should have been: dateInput.val(ngModel.$viewValue || ''); EDIT 2: The problem seems to be due to the isolate ...
0
votes
1answer
31 views

AngularJS directves: ng-click is not triggered after blur

DEMO Consider the following example: <input type="text" ng-model="client.phoneNumber" phone-number> <button ng-click="doSomething()">Do Something</button> ...
1
vote
1answer
12 views

Why ngModel's $render is not called when the model changes in AngularJS?

DEMO Why in the following example $render is not called when the button is clicked? <input type="text" ng-model="client.phoneNumber" phone-number> <button ...
2
votes
1answer
33 views

When ngModel's $render is called in AngularJS?

In this official example, what is the following code doing? // model -> view ctrl.$render = function() { elm.html(ctrl.$viewValue); }; As far as I can see, $render is never called. When ...
2
votes
2answers
33 views

Angular JS directive “@” $scope in-$digestion

Given: var myApp = angular.module('myApp', []); myApp.directive('myDirective', function () { return { restrict: 'E', scope: { classToAdd: '@' }, ...
0
votes
1answer
27 views

Selected option in select box with angularjs

I have an application developed using Codeigniter and AngularJs. I want to set a default item in manual select box, but angular adds an empty undefined item. <select class="form-control" ...
0
votes
1answer
43 views

Isolate Scope “=” binding and doted notation AngularJS

How do you create a 2 way binding with a nested property in an isolate scope with dotted notation. I thought 'myObject.data': "=data" would work, but it does not. I don't want to link everything in ...
0
votes
1answer
38 views

AngularJs : how to do a $watch on a function to evoid the error: $digest() iterations reached

I have a list with items. Each item of a list can be selected. If I select the item, it will be pushed in the cookies. In my home.html (here I have the list with the items that I can add to cookies) ...
1
vote
3answers
36 views

ng-bind happend after my directive so I don't have the value

I have a div element with ng-bind directive: <div ng-bind="sometext"></div> I have a directive that gets an element, checks its value / text and adds a color to the element according to ...
0
votes
1answer
43 views

AngularJS do link function after $http response returned

I need to perform a link function in a directive after an http response returns. The idea is something like this: <input type="text" my-field> <script> angular.module("mine") ...
2
votes
3answers
57 views

angularjs adding my own function to the existing ng-click

I have ng-click="foo()" which alert "foo" In my own directive, if ng-click is found, I want to add another function to alert "bar" I tried this DEMO: ...
0
votes
2answers
31 views

how to access object property via isolate scope without two-way binding?

I want to pass a product's id to a directive like so: <widget product-id="product.id"></widget> I prefer not to use curly braces: <widget ...
0
votes
2answers
44 views

Callback function in an angular directive

I want to have a call back function on a directive I wrote, without creating an isolated scope. The directive simply makes the element resizeable, and thus doesn't need a separate scope (and it's ...
1
vote
1answer
23 views

Can I create a directive without a module?

I typically have been defining my controllers as such: <body data-ng-app> <div data-ng-controller='IndexCtrl'> </div> </body> so my controller is defined: var ...
0
votes
1answer
36 views

Call another directive from the directive with the same attributes and content

I want to override behaviour of one library directive, called "ui-sref". Lets see example: <a ui-sref="edit" class="btn btn-small"> <i class="icon-pencil"></i> Edit </a> ...
1
vote
2answers
20 views

apply style property to ng-bind directive in angular js [on hold]

We have created the div using ng-bind directive in angular js. We are not able to apply style property to that same div <div ng-bind-html="test"></div> in contrller file i defined test ...
1
vote
0answers
31 views

angularjs apply filter cross nested directive?

I am new to angular, just created a angular tree with search filter... It loads nested data then fetch as a tree. but the problem here is I am not able to make the filter apply on child node data, ...
0
votes
0answers
40 views

Angular directive link function called twice

In my angular app, directives are working fine during the first visit, but once a page been visited twice, all the directive link function gets called twice too. Say I am on page A, click a link to go ...
0
votes
1answer
24 views

Unit Testing private functions in AngularJS Directive

How do I unit test a function that is defined inside a directive like the following myFunc? angular.module('myApp') .directive('myDir', [function () { var myFunc = function (arg) { // ...
2
votes
0answers
38 views

Can I change a directive's controller for different instances of the directive?

I have created a directive called modalDialog, which is basically that, a modal dialog. It uses transclude, so I can later do this in my code: <div modal-dialog id="dialog" dialog-title="This is ...
0
votes
2answers
33 views

Why ID of an element is changing after adding directive

I have number of divs getting created using ng-repeat. ID of those divs are assigned like this id={{""+date.getDate()+"-"+date.getMonth()+"-"+date.getFullYear()+"-"+time+":00"}} So ID of a div ...
0
votes
1answer
20 views

Testing angular directive that remove dom element doesn't work (at least for me…)

I've got a directive that removes a dom element upon some permission checking : angular.module('app').directive('permissionNeeded', function ($location, $route, SecurityService) { return { ...
1
vote
0answers
19 views

AngularJS: How to separate animation code from controller

In one of my controllers, I have a method triggers "grayOutBox". class Box ... grayOutBox: (delay = false) -> @state = '' if delay $timeout => @state = 'grayedOut' ...
0
votes
1answer
14 views

In angular, how do you provide a controller's argument list from within a directive definition?

I'm trying to follow the best practice of providing an argument list when defining a controller, like this: angular.module("myApp", []) .controller("myCtrl", ["$scope", function ($scope) { // ...
2
votes
2answers
26 views

AngularJS - disable float filtering

I'm creating a directive in AngularJs. Directive will receive from app controller a JSON object and based on that the directive will display the content. I made a simple demo based on my problem that ...
0
votes
2answers
37 views

weird behaviour of angularjs directive when wrapped

I have a directive like this, which wraps element with a container. app.directive('myDirective', function($compile, $timeout) { var num=0; return { link: function(scope, el, attrs) { ...

15 30 50 per page