FAQ Database Discussion Community


Directive Angularjs, $watch and HTML Element

html,angularjs,element,directive,watch
I have a question. I coded a HTML page with an angularjs directive this is my code <menufileupload visible="rightVisible" alignment="right"> <input type="text" ng-model='expr'/> <!--Other stuff--> </menufileupload> I'm trying to use a $watch to check any change in the text field $scope.$watch(...) only worked when the text field is out of...

AngularJS - Apply directive instantly, formating currency

javascript,angularjs,input,filter,directive
Ok so I have the following directive on various input elements. Some of those elements are on modals so The current method doesn't really work how I want, it should apply it right before the modal opens. crtPromoDir.directive('ngFormatCurr', ['$filter', function($filter) { function link(scope, element, attrs) { element.blur(function() { element.val($filter('currency')((element.val() ||...

Passing params to nested directives with isolated scope

angularjs,data-binding,scope,directive
I have an object data in the MainCtrl. This object is used to pass data to directives first-directive and second-directive. Two-data binding is neccesary in both cases. For first-directive, I pass the complete object data but for second-directive I want to pass numbers object (scope.numbers = scope.dataFirst.numbers). The problem: When...

AngularJs animate background color / colour

javascript,angularjs,colors,jquery-animate,directive
I have been trying to Dynamically Animate a background between 2 colours on click using AngularJs Directives and Controllers (with no success so far). Does anyone know how to do this? I have been trying to store the currCol (stored as an array var pushed into ng-class), but then I...

Apply CSS to AngularJS Directive Element Tag

html,css,angularjs,directive
Can I apply a CSS style to an AngularJS directive that has been defined as an element tag? I have the following simple directive: app.directive('popupHelp', function ($window) { return { restrict: 'A', link: function (scope, elem, attrs, ctrl) { elem.bind('click', function (e) { $window.open('http://www.google.com', 'popupHelpWindow', 'width=500,height=500'); console.log("I'm going to get...

How to access more than 2 DOM elements “The AngularJS way”?

html,angularjs,dom,directive
I'm starting to learn angularJS better, and I've noticed that AngularJS tries to make strong emphasis on separating the view from the controller and encapsulation. One example of this is people telling me DOM manipulation should go in directives. I kinda got the hang of it now, and how using...

How to track behavior of ngModel array item using .directive

javascript,angularjs,directive,watch,angular-ngmodel
Hi everyone I'm use angularjs not so long time ago and now I have one issue related with this framework that i can't to solve. So the problem in next: I have few input fields that generate via ng-repeat: <div class="form-group" ng-repeat="(i, name) in name_list track by $index"> <div class="row">...

angular directive to make input respond on enter

javascript,angularjs,angularjs-directive,directive
i apologize if the question is vague, i'm not quite sure how else to explain what i need. There are some dirty options which come to mind, but i'm a novice angular coder and i feel there is a clean simple method to implement this with directives maybe? what i...

AngularJS: Adding ng-click within element.append

angularjs,directive
Within my directive I have the following code, which will be used to continually append to an html element. //Establishes the type of question and therefore what should be displayed app.directive('questionType', function ($http, $compile) { return { restrict: 'A', link: function (scope, element, attr, model) { switch (scope.Question.inputType) { case...

AngularJS - directive with a dynamic array of objects in form

angularjs,directive,ng-repeat,angularjs-ng-model
I'm trying to create a form that has a dynamic set of input boxes. I'm trying to get ng-models to work with array items and I am clearly doing something wrong. My problem seems to be indexing the scope array lineItems in the template. Here is my jsfiddle: http://jsfiddle.net/dk253/9ykuuobq/ Here...

Angular Directive: bind 'mouseover' event to an element

javascript,angularjs,events,bind,directive
In my controller, I have the following array of users, which will be displayed by iteration in the partial html template in controller: vm.users = [ {"username": "johnDoe", "address": "Saltlake City, UT", "age": 34}, {"username": "janeDoe", "address": "Denver, CO", "age": 33}, {"username": "patrickDoe", "address": "San Francisco, CA", "age": 35} ];...

Do directives that share a required ^parent share parent's $scope?

angularjs,scope,require,directive
I'm having an issue where I'm using require in both myDirectiveChild1 -- C1 myDirectiveChild2 -- C1 The children's directive require: ^myDirectiveParent -- P P defines $scope.myVar but C1 and C2 seem to be over-writing the value of parent P's $scope.myVar instead of each having their own copy. Is that normal?...

AngularJS - Directive wrapping without losing connection to controller

javascript,angularjs,angularjs-directive,controller,directive
Is there a way for not losing connection to the current controller when you are wrapping data with a directive ? My problem is, that the directive within the wrapped template has no connection to the outside controller any more and so I can not execute the function. Wrapping Directive:...

ng-repeat not working within directive

angularjs,compilation,directive
I've created an Angular wrapper for drop.js which is a javascript library for popups. All works great within the drop directive including normal Angular bindings except when using ng-repeat. Here is a screenshot, notice the content of the popup has a value that is bound to the controller but the...

How can I use special characters in angular directives attributes?

javascript,angularjs,utf-8,special-characters,directive
I would like to use strings including german characters (Ä, Ö, Ü) in attributes of a custom angularJS directive. For example: <my-custom-directive my-label="Lärm" /> Another example is the ui.bootstrap.tabs directive: <tabset> <tab heading="Lärm"> content ... </tab> <tab heading="Second Heading"> content ... </tab> </tabset> This results in a tab with heading...

Angular js. Assign Controller with Directive

angularjs,directive,controllers
I try to connect the controller with the directive in Angular. Here html <div ng-controller="MyCtrl"> <div id='bbb' my-num>Click Me!</div> </div> I use the MyCtrl controller where I define tegid and mytitle. MainControl.controller('MyCtrl', ['$scope', function($scope) { $scope.tegid = ''; $scope.mytitle = 'aaa' + tegid; }]); Also I have the directive myNum...

how to simplify the