angularjs-directive

How to check if a component exists in Angular 1.5

和自甴很熟 提交于 2020-01-13 19:20:14
问题 http://embed.plnkr.co/oGlcQSOM2vFcDEKP7thV/ $injector.has('myMessageDirective') returns true, while $injector.has('myMessageComponent') does not Is anyone struggling with this or has a solution? My "fear" is that my components might not be found in future updates because of the directive check. Follow up question to: Check if an Angular directive exists 回答1: At the end of the day, a component is registered as a directive, so 'Directive' suffix is indeed needed. Check 'has' method of $injector

AngularStrap tooltip disables my custom directive

最后都变了- 提交于 2020-01-13 18:29:10
问题 I am trying to get the bs-tooltip AngularStrap directive to work with my own custom directive called "checkStrength" which checks the strength of a password. When using either of these directives alone, they work fine, but they won't work together. This is a plunker with the bs-tooltip. The tooltip works fine but my custom "checkStrength" directive does not work. This is a plunker without the bs-tooltip. In this case the "checkStrength" directive works fine. What am I doing wrong? 回答1: On

AngularJS: how to test directive which gives focus to element?

半世苍凉 提交于 2020-01-13 13:52:12
问题 Note: the suggested link is an answer to a question about a service, and doesn't give a clear explanation on how to solve this issue I'm trying to setup a karma test for my simple (and working) AngularJS autofocus directive: app.directive('autofocus', function ($timeout) { return { replace: false, link: function (scope, element, attr) { scope.$watch(attr.autofocus, function (value) { if (value) { $timeout(function () { element[0].focus(); console.log('focus called'); }); } } ); } }; }); This

Directive with templateUrl - testing with ng-html2js

陌路散爱 提交于 2020-01-13 10:36:10
问题 I created a directive with inline template, tested it, everything worked fine. Now I have put the template into separated .html file and reference it via templateUrl from directive. Directive works on my page, but the tests are broken saying: Error: [$injector:modulerr] Failed to instantiate module source/html/par tials/template-directive-my-directive.html due to: Error: [$injector:nomod] Module 'source/html/partials/template-directive -my-directive.html' is not available! You either

Angularjs directive remove watch?

本秂侑毒 提交于 2020-01-13 09:15:25
问题 I have a $scope.$watch declared in the controller of a directive. When I change pages and the directive is removed do I have to manually destroy the way? If so how do I detect when the directive has been removed? 回答1: It depends on the scope, not the directive. If the scope is destroyed, then all its $watchers die with it. On page change your scope'll be destroyed by angular, so you should be safe. When a scope dies it yields a $destroy event. You can watch it: $scope.$on('$destroy', callback

angular 2/4 multiple drop down

走远了吗. 提交于 2020-01-13 06:48:27
问题 I am trying to develop two drop downs in my Angular application. The 1st one is shop list and the other one is godown list . When I select a shop it will show it on data.but when I select Godown it's not changing data. Here I have two drop down boxes. I think my problem is in my typescript file(Onselect) because here I have 2 drop downs(in html I use 2 Onselect function but in my ts file have only one function). I'm just a beginner in Angular , so I would appreciate any comments on downsides

AngularJS - How do I change an element within a template that contains a data-binding?

爱⌒轻易说出口 提交于 2020-01-13 06:28:25
问题 What is the most Angular recommended way to use a dynamic tag name in a template? I have a drop-down containing h1-h6 tags. A user can choose any of these and the content will change to being wrapped by the chosen header tag (which is stored on the $scope). The content is bound to the model i.e. within {{ }}. To persist the binding I can change the markup and use $compile. However, this does not work because it gets appended (obviously) before Angular replaces the {{ }} with model values. It

How can I generate on the fly directives in AngularJS?

折月煮酒 提交于 2020-01-13 04:26:27
问题 I want to be able to take an array of strings, and then create directives based upon those strings. Either element or attribute will work fine but can't seem to get it working. <div ng-repeat="module in modules.directives"> <div {{module.directive}}></div> </div> <div ng-repeat="module in modules.directives"> <{{module.directive}}></{{module.directive}}> </div> <div ng-repeat="module in modules.directives"> <{{module.directive}} /> </div> Can't get any of these to work. Any ideas? 回答1: You

How to change the class on one div while hovering over another div with AngularJS?

蓝咒 提交于 2020-01-12 18:36:20
问题 I want to change the class of one div while hovering over another div using AngularJS directives. Here is what I have so far http://jsfiddle.net/E8nM5/38/ HMTL <div ng-controller="Ctrl" ng-app> <div ng-class="my-class">This div will change class when one hovers over bottom DIV </div> <br/> <div class="hover-div" ng-mouseenter="my-class = 'highlight'" ng-mouseleave="my-class = 'lowlight'">HOVER OVER ME TO CHANGE THE UPPER DIV's CLASS</div> </div> CSS div.highlight { padding: 10px; background:

How to change the class on one div while hovering over another div with AngularJS?

£可爱£侵袭症+ 提交于 2020-01-12 18:35:50
问题 I want to change the class of one div while hovering over another div using AngularJS directives. Here is what I have so far http://jsfiddle.net/E8nM5/38/ HMTL <div ng-controller="Ctrl" ng-app> <div ng-class="my-class">This div will change class when one hovers over bottom DIV </div> <br/> <div class="hover-div" ng-mouseenter="my-class = 'highlight'" ng-mouseleave="my-class = 'lowlight'">HOVER OVER ME TO CHANGE THE UPPER DIV's CLASS</div> </div> CSS div.highlight { padding: 10px; background: