angularjs-directive

Trigger click events while button is pressed

*爱你&永不变心* 提交于 2019-12-23 15:21:35
问题 I am creating a directive that moves an element to the right. In each click, the item is moved to the right, but I would like that the element moves as long I am keeping the button pressed. .directive("car", function(){ return { restrict:"A", link:function(scope,element,attrs,controller){ var left=0; var car = angular.element(element[0].querySelector('.car')); var move = function(e){ left+=10; car[0].style.left = left+"px"; }; element.on("click", move); } }; }) So how can I detect when the

Angularjs Multiple directives [gridsection, gridsection] asking for template on: <div gridsection=“”>

三世轮回 提交于 2019-12-23 14:59:28
问题 I'm receiving the error: Multiple directives [gridsection, gridsection] asking for templateon : <div gridsection=""> with this code. I don't see how i'm using nested directives or what is causing this. html page <div gridsection ></div> directive angular.module('web').directive('gridsection', function() { return { restrict: 'A', replace: false, scope: { patient: "=patient" }, templateUrl: 'directive/section.html', link: function(scope, element, attrs, fn) { } }; }); directive/section.html

Passing data from ng-click within directive into a function in the controller

只愿长相守 提交于 2019-12-23 13:01:12
问题 I found this question which gets me almost to where I need to be. Why doesn't ng-click work in my directive and how do I add a toggle class? Which makes it so my ng-click within my directive template triggers a function in my controller. http://plnkr.co/edit/GorcZZppa8qcIKbQAg2v?p=preview The issue is that the parameter returned to my controller (item) is undefined . I need this to actually pass data from a variable within my directive to be used in the function that I will run in the

Endless scroll doesn't work in AngularJS when scrolling over a ng-view

岁酱吖の 提交于 2019-12-23 12:54:04
问题 I am using code like this to create an endless scroll effect in AngularJS. I tried to refactor some of the code, by moving the content of the scrollable container (in this case the ul ) to a seperate html file, and then use a ng-view to load the content. After this is done the scope.$apply(attr.whenScrolled); doesn't have any effect. The loadMore() method is simply not called anymore. Have I changed something about the scope after moving the ul-content to a seperate file, and loading it in

How to determine if an optional function has been passed into an Angular directive?

别说谁变了你拦得住时间么 提交于 2019-12-23 12:45:40
问题 I have a directive that displays some data but I want to user of the directive to be able to control how that data is displayed. I would like to allow a user to be able control the display using one of three options. pass in a string to use for the display pass in a function that will be called to generate the string or just show the raw data I can't post the code for the entire directive (NDA and all) but it is a directive for showing a ring chart using D3. The number in the middle is the

How do I ngShow and ngHide two different elements at the same time with AngularJS?

依然范特西╮ 提交于 2019-12-23 12:28:10
问题 So I have two elements that are exclusive: <span>foo</span> <span>bar</span> And I added ngShow and ngHide to them: <span ng-show="fooTime">foo</span> <span ng-hide="fooTime">bar</span> But now when these render, there is a split second where they both show. How can I make them show/hide at the same time? 回答1: Use a ngSwitch rather than an ngShow/ngHide: <span ng-switch="fooTime"> <span ng-switch-when="true">foo</span> <span ng-switch-when="false">bar</span> </span> Why? When using the

AngularJS directive link function not being called

大兔子大兔子 提交于 2019-12-23 11:48:10
问题 I am trying to use angular-http-auth library with bootstrap modal window. Modals are working fine but I have problems with directives. Here is a jsfiddle link - http://jsfiddle.net/jCUSh/85/ . I am trying to add a directive that will be invoked and that adds listeners. I have simplified the example in jsfiddle, so you won't see http-auth imports. However scope.on('') elements are still left (they don't break the picture anyway). My question is - why isn't the linking function called? I added

AngularJS directive link function not being called

青春壹個敷衍的年華 提交于 2019-12-23 11:48:00
问题 I am trying to use angular-http-auth library with bootstrap modal window. Modals are working fine but I have problems with directives. Here is a jsfiddle link - http://jsfiddle.net/jCUSh/85/ . I am trying to add a directive that will be invoked and that adds listeners. I have simplified the example in jsfiddle, so you won't see http-auth imports. However scope.on('') elements are still left (they don't break the picture anyway). My question is - why isn't the linking function called? I added

How can I put multiple values for ng-disabled in angular js?

帅比萌擦擦* 提交于 2019-12-23 10:33:45
问题 How can I put multiple values for ng-disabled in angular js? My problem is explained with this following JS fiddle: http://jsfiddle.net/FJf4v/10/ <div ng-app> <div ng-controller="myCnt"> <h3>A ->> <input type="checkbox" ng-model="check"> </input></h3> <h3>B ->> <input type="checkbox" ng-model="check"> </input></h3> <br/> <input type="checkbox" ng-disabled="check">Chkbox1 to be disabled</input> <input type="checkbox" ng-disabled="check">Chkbox2 to be disabled</input> <hr/> </div> </div>

Remove DOM-Element with AngularJS

混江龙づ霸主 提交于 2019-12-23 10:23:03
问题 I'm trying to remove a navbar based on the current location path. This is what I have so far: angular.module('myModule') .controller('MainController', function ($location, $document) { if ($location.path().indexOf('resetpass') > -1) { var navbar = angular.element($document.querySelector(".top-navbar")); navbar.remove(); } }); With this approach the console says: angular.js:14110 TypeError: $document.querySelector is not a function at new <anonymous> (main.controller.js:6) at Object.invoke