directive

Template-Url Directive Unit Testing without Karma

匿名 (未验证) 提交于 2019-12-03 01:45:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: SOLUTION = Solution Plunker I have tried manually passing the template in testing - is it even good way of doing it ? How to make it passes !!!!!!! How to write unit test for Simple directive with template-Url without Using Karma . I have tried following after seeing examples on stack-overflow but no success. Directive app.directive("crazy", function () { return { restrict: "A", templateUrl:"directivetemplate.html" }; }); Spec describe('Directive: crazy', function () { beforeEach(module('plunker')); beforeEach(inject(function($templateCache)

Ellipsis directive with title

匿名 (未验证) 提交于 2019-12-03 01:36:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an Angular directive that adds styling text-overflow: ellipsis; overflow: hidden; white-space: nowrap; in ngOnInit and then looks something like this: @Directive({ selector: 'ellipsis' }) class EllipsisDirective { ngAfterViewInit() { const el: HTMLElement = this.el.nativeElement; if (el.offsetWidth < el.scrollWidth) { el.setAttribute('title', el.innerText); } } } Usage: <div ellipsis>Some Very Long Text Here</div> The problem: On some pages, the layout/components do not change on a 'navigate', only the data does. Currently the

Angular2 Error: There is no directive with “exportAs” set to “ngForm”

匿名 (未验证) 提交于 2019-12-03 01:26:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i'm on the RC4 and i'm getting the error There is no directive with "exportAs" set to "ngForm" because of my template : <div class="form-group"> <label for="actionType">Action Type</label> <select ngControl="actionType" ===> #actionType="ngForm" id="actionType" class="form-control" required> <option value=""></option> <option *ngFor="let actionType of actionTypes" value="{{ actionType.label }}"> {{ actionType.label }} </option> </select> </div> the boot.ts : import {disableDeprecatedForms, provideForms} from '@angular/forms'; import

Vue directive to access the Vue instance?

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How do you access the Vue instance from a directive? I have this HTML <div id='vueApp' v-init='my initial data from server-side'> and this script var app = new Vue({ el: '#vueApp', data: { myData: null } }); Vue.directive('init', function(el, binding) { app.myData = binding.value; }); It throws this error: Failed to resolve directive: init 回答1: Your particular error is because the directive is created after the Vue. For this particular directive, you could access the Vue through vnode.context . Vue.directive('init', { bind(el, binding, vnode

Passing data to a custom directive in AngularJS

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a page that displays a bunch of thumbnails of images that are retrieved using http. I use ng-repeat to go through the array and generate the html. This works fine. I also create a custom directive that I tie as an attribute to img elements generated by ng-repeat. This also works fine. However, when I try to pass data to the scope of my custom directive then it all falls apart. Data binding fails, ng-repeat does not replace the url of the images so I end up getting a 404 since the url is invalid. That is pretty much as far as

Isolating directive scope but preserve binding on ngModel

匿名 (未验证) 提交于 2019-12-03 01:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a directive that will use ng-model to expose its value. The question is that this directive have internal components that will also mess the scope, so I need to isolate its scope, but still preserve ng-model bind to outside world. How would I achieve this? This is the directive: angular . module ( 'app' , []). directive ( 'myDirective' , function () { return { restrict : 'E' , require : 'ngModel' , link : function ( scope , element , attr , ngModel ) { // do stuff using ngModel controller }, replace : true , template : '<div

AngularJS - bind to directive resize

匿名 (未验证) 提交于 2019-12-03 01:12:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How can i be notified when a directive is resized? i have tried element[0].onresize = function() { console.log(element[0].offsetWidth + " " + element[0].offsetHeight); } but its not calling the function (function() { 'use strict'; // Define the directive on the module. // Inject the dependencies. // Point to the directive definition function. angular.module('app').directive('nvLayout', ['$window', '$compile', layoutDirective]); function layoutDirective($window, $compile) { // Usage: // // Creates: // var directive = { link: link, restrict:

Cabal error: invalid preprocessing directive #-}

匿名 (未验证) 提交于 2019-12-03 01:11:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: $ cabal install arithmoi-0.4.0.3 results in multiple errors like: Math/NumberTheory/Moduli.hs:489:4: error: invalid preprocessing directive #-} ^ My System: OSX Mavericks Cabal version = 1.18.1.1 GHCI version = 7.6.3 Thanks in advance! 回答1: Possible workaround here . xCode 5 comes with clang as c/c++/obj-c compiler. Haskell Platform is not ready for that. The next ghc release will fix that. Also see here . 文章来源: Cabal error: invalid preprocessing directive #-}

Decorating the ng-click directive in AngularJs

匿名 (未验证) 提交于 2019-12-03 01:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've been looking into modifying the AngularJS ng-click directive to add some additional features. I have a few different ideas of what to use it for, but a simple one is to add Google Analytics tracking to all ng-clicks, another is to prevent double clicking. To do this my first thought was to use a decorator. So something like this: app.config(['$provide', function($provide) { $provide.decorator('ngClickDirective', ['$delegate', function($delegate) { // Trigger Google Analytics tracking here return $delegate; }]); }]); But this won't work

Use an angular directive inside another directive

匿名 (未验证) 提交于 2019-12-03 01:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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 '); } } }) wizardModule.directive('parentDirective', function ($http, $compile) { return { restrict: 'E', compile: function (element, attrs) { var x = ' '; element.append(x); } } This was