angularjs-directive

Angular directives - element or attribute?

人走茶凉 提交于 2019-12-17 18:10:59
问题 I'm part of a team with about 6 UI devs, of varying quality and next to no Angular experience. Many are contractors, with little experience with the code base. The app has a very fancy (complicated) UI. It supports IE8+ (soon hopefully IE9+). We're introducing Angular for a major extension to the app, and I've been asked to write guidelines on the use of Angular for the team. We'll use directives to create fancy UI elements, all prefixed with "ipwr" to avoid name clashes. I'm trying to decide

Angular directives - element or attribute?

天涯浪子 提交于 2019-12-17 18:08:47
问题 I'm part of a team with about 6 UI devs, of varying quality and next to no Angular experience. Many are contractors, with little experience with the code base. The app has a very fancy (complicated) UI. It supports IE8+ (soon hopefully IE9+). We're introducing Angular for a major extension to the app, and I've been asked to write guidelines on the use of Angular for the team. We'll use directives to create fancy UI elements, all prefixed with "ipwr" to avoid name clashes. I'm trying to decide

How to add ng-model functionality to a component

两盒软妹~` 提交于 2019-12-17 16:54:38
问题 Angular ng-change on ng-model passed into child directive Basically, I want to be able to pass in ng-model from a parent directive to a child directive. I could just in a 2-way binded value, but then I wouldn't be able to use a ng-change in the parent directive on the child element. I could also use ng-click, but this wouldn't work with a non-clicking change (such as a text area instead of a checkbox). So I'm wondering if there's a way to allow a custom directives to have a ng-model/ng-change

AngularJS: Linking to elements in a directive that uses ng-repeat

末鹿安然 提交于 2019-12-17 15:37:32
问题 I have a simple directive where the template uses ng-repeat inside it. I need to run some code to instantiate a jquery component against some of the elements created by the ng-repeat directive. The problem is that if I put this code in the link function. The ng-repeat hasn't built those elements yet so nothing is instantiated. App.directive('myDirective', ['$compile', '$timeout', function($compile, $timeout) { return { scope: { domains: '=' }, templateUrl: '/app/partials/my_directive.html',

How do I use angularjs directives in generated d3 html?

纵饮孤独 提交于 2019-12-17 15:35:58
问题 I'm trying to use the angularjs tooltip directive on my d3 visualisation, so I have something like var node = svg.selectAll(".node") .data(nodes) .enter().append("circle") .attr("tooltip-append-to-body", true) .attr("tooltip", function(d) { return d.name; }) // ... attributes However, the tooltips are not showing. Do I need to $compile or something? I've tried wrapping it around $timeout too, but that didn't work. 回答1: I had a similar problem and yes, solved it with $compile . I'm assuming

How to add dynamic row to a table using angularjs

醉酒当歌 提交于 2019-12-17 15:35:48
问题 Like jQuery, How can I add dynamic rows to a table with form elements in a button click using angularjs and How to differentiate these form elements like array name in normal jquery submit. <tr> <td style="text-align:center">1</td> <td> <input type="text" class="form-control" required ng-model="newItem.assets"> </td> <td> <select ng-model="newItem.type" class="form-control"> <option value="Rent" ng-selected="'Rent'">Rent</option> <option value="Lease">Lease</option> </select> </td> <td>

Use an angular directive inside another directive

南笙酒味 提交于 2019-12-17 15:33:26
问题 I have created the below angular directives, ChildDirective that is used inside ParentDirective var wizardModule = angular.module('Wizard', []); wizardModule.directive('childDirective', function ($http, $templateCache, $compile, $parse) { return { restrict: 'E', scope: [], compile: function (iElement, iAttrs, transclude) { iElement.append('child directive<br />'); } } }) wizardModule.directive('parentDirective', function ($http, $compile) { return { restrict: 'E', compile: function (element,

Is it Possible to Update Parent Scope from Angular Directive with scope: true?

橙三吉。 提交于 2019-12-17 15:25:16
问题 I have a need for inheriting scope from a parent controller in a directive. I don't necessarily want to leave scope: false. I also don't necessarily want to use an isolated scope, because it requires a lot of work to get the values I do care about linked properly (think lots of values in a parent controller). Does it make sense to use scope:true in my directive if I want to update parent scope? <div ng-controller="MyCtrl"> Hello, {{name}}! <my-directive></my-directive> </div> var myApp =

AngularJS : Differences among = & @ in directive scope? [duplicate]

不羁岁月 提交于 2019-12-17 14:59:23
问题 This question already has answers here : What is the difference between '@' and '=' in directive scope in AngularJS? (18 answers) Closed 5 years ago . Creating an isolate scope inside a directive lets us map the outer scope to the inner scope . We have seen six different ways to map to attrbutes: =attr &attr @attr = & @ What do each of these scope mapping options do? 回答1: This can be confusing but hopefully a simple example will clarify it. First, let's separate model bindings from behaviors.

creating a new directive with angularjs

早过忘川 提交于 2019-12-17 13:09:33
问题 so i'm making a simple directive called "hover", it's a basic nav menu that when you pass a mouse over a specific aba, this aba changes the color. See my script code: var app = angular.module('myModule', []); app.directive('hover', function(){ return{ restrict: 'E', controller: function($scope) { $scope.hover = null; $scope.selected = null; $scope.onHover = function (index){ $scope.hover = index; } $scope.mouseLeave = function(){ if($scope.selected) $scope.hover = $scope.selected; else $scope