All Questions
Tagged with angularjs-directiveangularjs
1,613 questions
18votes
3answers
5kviews
Is this a "Deferred Antipattern"?
I'm finding it hard to understand the "deferred antipattern". I think I understand it in principal but I haven't seen a super simple example of what a service, with a differed promise and one with ...
1111votes
18answers
571kviews
What is the difference between '@' and '=' in directive scope in AngularJS?
I've read the AngularJS documentation on the topic carefully, and then fiddled around with a directive. Here's the fiddle. And here are some relevant snippets: From the HTML: <pane bi-title="...
774votes
33answers
653kviews
How to set focus on input field?
What is the 'Angular way' to set focus on input field in AngularJS? More specific requirements: When a Modal is opened, set focus on a predefined <input> inside this Modal. Every time <input&...
128votes
14answers
124kviews
Controller not a function, got undefined, while defining controllers globally
I am writing a sample application using angularjs. i got an error mentioned below on chrome browser. Error is Error: [ng:areq] http://errors.angularjs.org/1.3.0-beta.17/ng/areq?p0=...
541votes
7answers
236kviews
When to favor ng-if vs. ng-show/ng-hide?
I understand that ng-show and ng-hide affect the class set on an element and that ng-if controls whether an element is rendered as part of the DOM. Are there guidelines on choosing ng-if over ng-...
199votes
7answers
111kviews
Add directives from directive in AngularJS
I'm trying to build a directive that takes care of adding more directives to the element it is declared on. For example, I want to build a directive that takes care of adding datepicker, datepicker-...
96votes
6answers
60kviews
angular ng-bind-html and directive within it
Plunker Link I have a element which I would like to bind html to it. <div ng-bind-html="details" upper></div> That works. Now, along with it I also have a directive which is bound to ...
78votes
7answers
61kviews
AngularJS 1.5+ Components do not support Watchers, what is the work around?
I've been upgrading my custom directives to the new component architecture. I've read that components do not support watchers. Is this correct? If so how do you detect changes on an object? For a ...
336votes
6answers
275kviews
How to access parent scope from within a custom directive *with own scope* in AngularJS?
I'm looking for any manner of accessing the "parent" scope within a directive. Any combination of scope, transclude, require, passing in variables (or the scope itself) from above, etc. I'm totally ...
300votes
13answers
339kviews
How to call a method defined in an AngularJS directive?
I have a directive, here is the code : .directive('map', function() { return { restrict: 'E', replace: true, template: '<div></div>', link: function($...
428votes
19answers
516kviews
How to use a keypress event in AngularJS?
I want to catch the enter key press event on the textbox below. To make it more clear I am using a ng-repeat to populate the tbody. Here is the HTML: <td><input type="number" id="closeqty{{$...
218votes
6answers
269kviews
How to set an iframe src attribute from a variable in AngularJS
I'm trying to set the src attribute of an iframe from a variable and I can't get it to work... The markup: <div class="col-xs-12" ng-controller="AppCtrl"> <ul class=""> <...
112votes
4answers
62kviews
Why is `replace` property deprecated in AngularJS directives? [duplicate]
According to the API docs, directives' replace attribute is deprecated, so in the future, all directives will behave with the current default of replace: false. This removes developers' ability to ...
454votes
8answers
158kviews
Angular directives - when and how to use compile, controller, pre-link and post-link [closed]
When writing an Angular directive, one can use any of the following functions to manipulate the DOM behaviour, contents and look of the element on which the directive is declared: compile controller ...
95votes
2answers
107kviews
How to use the 'replace' feature for custom AngularJS directives?
Why does replace=true or replace=false not have any impact in the code below? Why isn't the "some existing content" being displayed when replace=false? Or putting it more humbly, can you kindly ...