Linked Questions
95 votes
2 answers
56k views
Directive isolate scope with ng-repeat scope in AngularJS
I have a directive with an isolate-scope (so that I can reuse the directive in other places), and when I use this directive with an ng-repeat, it fails to work. I have read all the documentation and ...
39 votes
7 answers
64k views
Callback function inside directive attr defined in different attr
So I have this directive called say, mySave, it's pretty much just this app.directive('mySave', function($http) { return function(scope, element, attrs) { element.bind("click", function() { ...
26 votes
10 answers
79k views
Input autofocus attribute
I have places in my code where I have this: <input data-ng-disabled="SOME_SCOPE_VARIABLE" /> I would like to be able to use it like this too: <input data-ng-autofocus="SOME_SCOPE_VARIABLE" /...
15 votes
5 answers
66k views
AngularJS Custom Directive Two Way Binding
If I have an AngularJS directive without a template and I want it to set a property on the current scope, what is the best way to do it? For example, a directive that counts button clicks: <...
23 votes
4 answers
21k views
How to use ng-show on a directive that has an isolated scope
I have a directive that I use like this: <dir model="data"></dir> The directive has an isolated scope. scope :{ model:'=' } Now I'm trying to use ng-show on that directive using ...
22 votes
4 answers
27k views
Can I use ng-model with isolated scope?
I am creating simple ui-datetime directive. It splits javascript Date object into _date, _hours and _minutes parts. _date uses jquery ui datepicker, _hours and _minutes - number inputs. angular....
19 votes
1 answer
8k views
Why does ng-style not work on the same element as a custom directive?
I'm trying to apply the ng-style attribute on a custom directive tag, kind of like so: <my-directive ng-style="myStyle"></my-directive> Inside the controller I have: $scope.myStyle = { ...
7 votes
2 answers
5k views
How to prevent that a scope is shared among directives n Angular?
All my directives use the same scope and I want my directives to operate by their own. Directive: app.directive('headerSort', function () { return { restrict: 'A', controller: ...
3 votes
3 answers
8k views
Angular communication between controllers and directives
I have this piece of code which allows a user to leave comments on a list of items. I created a directive and listen to keydown in order to let the user submit a comment if keyCode == 13. Not sure ...
0 votes
2 answers
3k views
Angular two different directives with same controller share scope
I'm creating two directives which use the same controller, as a result I see that both directives share data among controller. What I want is that data to be UNIQUE per directive, so data shouldn't be ...
5 votes
1 answer
2k views
Why formatters does not work with isolated scope?
Why formatters does not work with isolated scope? Is this angular bug or I am doing something wrong? This contains isolates scope and does not work: http://jsfiddle.net/YbdXQ/56/ restrict: 'A', ...
7 votes
1 answer
5k views
Evaluating an expression in an attribute of a directive in AngularJS
I did a lot of workaround, searched and researched, but I can't figure how to achieve my goal. - The problem: I have a the following situation, I want to avoid the user can overlap commissions dates ...
2 votes
3 answers
3k views
Multiple AngularJS directives with different scopes
Hi I have a two popup directives on the same page. The problem is when I click on one they both pop up. How can I isolate each scope from each other so only the popup that's clicked pops up? HTML &...
2 votes
2 answers
2k views
How to make sibling directives communication work( communication between certain specific directive)
All: Suppose I have two directives( dir1 and dir2) , which are both isolated scope. From some posts, I learnt that I need to use "require" to get scope of the other directive, but there is one ...
2 votes
3 answers
2k views
How to watch and re-evaluate expression in directive?
I am trying to write custom directive and one of the requirements is that I should be able to disable one of the elements based on the expression set on attribute of the directive. Directive is ...
1 vote
1 answer
1k views
Developing widgets in one view in Angular.js
I’d appreciate if you could share you view/experience. Suppose you have a view which contains several widgets that share some of the data (fetched from a server). For example we might have a tree, ...
0 votes
2 answers
1k views
AngularUI modal custom scope
I wanted to define a custom scope for the modal (I don't want to use dependency injection for reasons) I am using in my project, but I'm getting an error whenever I define a scope in $modal.open. Here ...
1 vote
1 answer
2k views
ng-change and ng-focus not working in custom input directive
I'm working on customize a input directive which including a label. I tried several days and refer to some articles. The only problem is that except ng-change, ng-blur and ng-focus, all the other ...
0 votes
1 answer
422 views
How should I $eval an attribute in a directive when used with ng-repeat?
I have a very simple directive that does not have an isolate scope. It's being used on a ng-repeat element and I want to limit which element out of that ng-repeat it works on. It doesn't work on ...
0 votes
2 answers
264 views
AngularJS: How to access scope from directive
I'm using a directive to draw graphs: drawGraph.directive "graph", -> restrict: "E" # Use as element scope: # Isolate scope data: "=" # Two-way bind data to local scope opts: "=?" # '?'...
3 votes
1 answer
137 views
How can I change the scope of my element from an attribute directive?
<input type='text' ng-model='foo' my-dir='customFunction' /> {{foo}} .directive('myDir',function(){ scope:{ customFunc : "&myDir"}, }); Now the scope will be overridden with myDir and ...
0 votes
1 answer
282 views
Scopeless directives - how to get data?
I'm using scopeless directives (https://github.com/johnpapa/angularjs-styleguide#directives-and-controlleras). <directive1> <directive2></directive2> </directive2> In ...
4 votes
2 answers
108 views
Why does the parent scope break when nesting a directive using controllerAs
My web application has several pages who have their own controller. Inside these pages I use directives who also have a controller. All controllers use the controllerAs syntax and they are all set as ...
0 votes
0 answers
138 views
how to pass scope variables from controller to directive
I want to pass the scope variables defined in the 'MapCtrl' to the 'mapCanvas' directive. As the code stands the console.log returns undefined. Does anyone know how I can pass the variables from my ...
0 votes
1 answer
133 views
Show Variables on Markup Using Angular Directive With Isolate Scope
I have a directive with an isolate scope and its own controller. I'd like to pass a value from the parent scope and print out its value onto the markup. I thought I could merely pass it like this: ...
0 votes
1 answer
57 views
How would I share scope between an angular controller and a directive
I'm trying to do something similar to this fiddle. What I expect to happen is that a select list is displayed and when one of the options is selected the word true or false is displayed on this line ...