FAQ Database Discussion Community


Directive with transclude, data binding not working in templateUrl

angularjs,angularjs-directive,angularjs-scope,directive
I have a directive with transclude:true. However, the data binding works when i use a template:"" but not when i use templateUrl:"" Below you can find my directive. The rsCarousel.html template contains the same code as the template"" property. When using the template property i get the vm.carouselId on screen...

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...

ng-class expression: merge condition and class name

javascript,angularjs,expression,directive,ng-class
Supposing I have 3 variables (they can change its value): $scope.A = 'one'; $scope.B = true; $scope.C = false; <div ng-class="A"></div> renders <div class="one"> <div ng-class="{'two': B, 'three': C}"></div> renders <div class="two"> How can I merge a variable and a expression to render <div class="one two">? Do I have to...

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...

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...

Corrent means of coding a directive in Angular

angularjs,directive
I have some code here <div ng-repeat="student in students" class="student"> <div class="col-md-2"> <div class="row placeholder"> <img data-src="holder.js/200x200/auto/sky" class="img-responsive profile" alt="200x200" src="#" data-holder-rendered="true"> </div> </div> <div class="col-md-10" style="padding: 17px 40px;"> <div class="row"><h1 class="name"><a href="/database/profile.php?id=2015552117"><span>{{ student.FirstName }}</span> {{ student.LastName }} , {{...

Insert an HTML Tag Into an Angular Directive

html,angularjs,dom,tags,directive
I want to use an Angular directive to wrap a Bootstrap panel. I'm running into a problem, though, if I want to use HTML tags within the body of the panel. Given: $scope.panel = { title: "Title", body: "This is some <strong>cool</strong> text!" }; I would want my panel to...

How to set value to element in directive template with jQuery

javascript,jquery,angularjs,angularjs-directive,directive
I have some directive and some template in it. angular.module('testModule', []) .directive('testInput', function () { var id = 1; return { restrict: 'E', replace: true, scope: { model: '=' }, template: '<div><input type="text" id="{{uniqueId}}"/></div>', link: function (scope) { scope.uniqueId = "test" + id++; $('#' + scope.uniqueId).val(33); } } }); I...

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} ];...

Angularjs directive call controller function

javascript,angularjs,controller,directive
i have a directive which renders a long list. The Rendering works pretty fine and fast, now i would like to call a function on the Controller with Parameters. How can i achieve this? Here is my directive: .directive("slheats", function () { return { restrict: "A", scope: { slheats: "=",...

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...

how to simplify the