FAQ Database Discussion Community

angular directive to make input respond on enter

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 correctly implement in AngularJs: Custom directive reuse several times in single page

I created a custom directive that has event handler on it and use it 3 times. <div sl-entity-browser btn_label="Browse supplier" handler="supplier_selection_handler(entity)" /> <div sl-entity-browser btn_label="Browse checker" handler="checker_selection_handler(entity)" /> <div sl-entity-browser btn_label="Browse approving officer" handler="approvar_selection_handler(entity)" /> In my controller: $scope.supplier_selection_handler = function(entity){ $scope.selectedSupplier = entity; } $scope.checker_selection_handler =...

ng-repeat not working within 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 to use $compile inside an Angular directive?

I have a collection of 500 items (persons) that I am rendering in an Angular ng-repeat directive. Each item has three fields (FirstName, LastName, Company). I want the user to be able to see details / edit the items below each rendered row. I have a button (Font Awesome square-plus)...

Apply CSS to AngularJS Directive Element Tag

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

ng-class expression: merge condition and class name

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

how to simplify the