Tagged Questions
13
votes
3answers
515 views
When writing a directive, how do I decide if a need no new scope, a new child scope, or a new isolate scope?
I'm looking for some guidelines that one can use to help determine which type of scope to use when writing a new directive. Ideally, I'd like something similar to a flowchart that walks me though a ...
6
votes
1answer
62 views
Directives callbacks and scope
I'm trying to wrap my head around scopes in angularjs, particularly when it comes to invoking callbacks on the module that is using a directive. I've found 3 different ways to accomplish the same ...
6
votes
1answer
49 views
AngularJS: Two way data binding fails if element has ngModel and a custom directive
I made two directives to setup custom error messages in AngularJS:
errors -> displays the error messages for a form
error-message -> sets up a custom error message on an input
For some reason ...
4
votes
1answer
56 views
How to stop $broadcast events in AngularJS?
Is there a built in way to stop $broadcast events from going down the scope chain?
The event object passed by a $broadcast event does not have a stopPropagation method (as the docs on $rootScope ...
3
votes
1answer
21 views
How do I stop $watching in AngularJS?
I can set up a $watch on an AngularJS scope to be notified when the expression I am interested in has changed. But how do I stop watching once I lose interest?
3
votes
3answers
258 views
angular-bootstrap (tabs): data binding works only one-way
I prepared a little fiddle and boiled it down to the minimum:
http://jsfiddle.net/lpeterse/NdhjD/4/
<script type="text/javascript">
angular.module('app', ['ui.bootstrap']);
function ...
3
votes
1answer
62 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 = {
...
2
votes
3answers
110 views
Angular.js watch only on particular object property
Basically I want this http://plnkr.co/edit/3yfXbo1c0llO40HZ8WNP?p=preview but watch doesn't fire when I change something..
I know that this would have worked
$scope.$watch('stuff', function (oldVal, ...
2
votes
2answers
104 views
$watch not being triggered on array change
I'm trying to figure out why my $watch isn't being triggered. This is a snippet from the relevant controller:
$scope.$watch('tasks', function (newValue, oldValue) {
//do some stuff
//only ...
2
votes
1answer
104 views
Angular : Update model from directive
I have a fiddle up here: http://jsfiddle.net/KdkKE/44/
What I'd like to do create a 'toggle' component, basically a custom checkbox but with html that changes if it is true or false, which is bound ...
2
votes
2answers
24 views
Isolated scope with simple angularjs nested directive
Please check this plnkr
I have read everyhting can find about directives, scope and isolated scopes. But I still cannot understand the way to make this work.
The directive I created works perfectly ...
2
votes
2answers
171 views
Sending event when angular.js finished loading
wondered what's the best way to detect the finish of page loading/bootstrapping, when all directives done compiling/linking
any event already there? should i overload the bootstrap function?
thanks ...
2
votes
1answer
63 views
angularjs: setting focus on a previously-hidden input element inside a directive
Here is a simplified plunk to illustrate the problem
I got an angular directive that compiles some html code before visualizing it. In the html, there is an hiden input that becomes visible only if ...
2
votes
3answers
116 views
How to watch an array for changes in AngularJS
I basically want the equivalent to binding to 'add' and 'remove' events in Backbone's Collections. I see basically no way of doing this in AngularJS, and the current workaround we've settled for is ...
2
votes
2answers
79 views
Directive isolate scope with ng-repeat scope
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 ...