Skip to main content

All 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 ...
Aleski's user avatar
  • 1,442
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="...
iwein's user avatar
  • 26.2k
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&...
Misha Moroshko's user avatar
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=...
yokks's user avatar
  • 5,773
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-...
Patrice Chalin's user avatar
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-...
frapontillo's user avatar
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 ...
Amitava's user avatar
  • 5,083
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 ...
Ka Tech's user avatar
  • 9,497
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 ...
colllin's user avatar
  • 9,789
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($...
mcbjam's user avatar
  • 7,484
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{{$...
Venkata K. C. Tata's user avatar
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=""> <...
emersonthis's user avatar
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 ...
sbleon's user avatar
  • 1,685
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 ...
Izhaki's user avatar
  • 23.6k
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 ...
Kaya Toast's user avatar

153050per page
close