directive

How to access controllerAs namespace in unit test with compiled element?

送分小仙女□ 提交于 2019-12-01 17:27:21
问题 In this fiddle http://jsfiddle.net/FlavorScape/fp1kktt9/ i try to set properties on the controller, not the $scope directly. In the template (in production) we just do myAliasCtrl.somePropertyList and the ng-repeat works. However, this does not work in testing. I don't know how to get/assign the property on the controller. UPDATE: I must have had some weird localized issue in my testing environment, because i do get ng-repeat to work. notice how there's two child elements, even though the

Can specific Delphi hints be disabled?

跟風遠走 提交于 2019-12-01 02:34:58
In Delphi, you can use compiler directives to disable specific warnings, such as {$WARN USE_BEFORE_DEF OFF} But when I tried to do that with a specific hint, whose underscore_style_name I got out of the helpfile, the compiler said it doesn't know what {$HINT} is. So is there any way to do this? No specific hints, but you can disable them all. {$HINTS OFF} procedure MyProc; var i : integer; begin DoSomething; end; {$HINTS ON} Little off-topic: You should take care about compiler's hints and warnings. They are not just for fun. Compiler is just saying "program may work differently that you think

angular 2 typescript An implementation cannot be declared in ambient contexts

﹥>﹥吖頭↗ 提交于 2019-11-30 22:44:27
问题 I am new to typescript and I am trying to create a function for an angular 2 directive. Can anyone explain, in language for n00bs, what the error is trying to tell me when I am compiling with Gulp? An implementation cannot be declared in ambient contexts The message applies to offset() and toggler() . import { Directive, ElementRef, Input } from '@angular/core'; @Directive({ selector: 'offCanvas', inputs: ['target', 'toggle', 'placement', 'autohide', 'recalc', 'disableScrolling', 'modal',

AngularJS - Append element to each ng-repeat iteration inside a directive

淺唱寂寞╮ 提交于 2019-11-30 16:30:03
I'm using a ng-repeat inside a <tr> element together with a directive. Html: <tbody> <tr ng-repeat="row in rows" create-table> <td nowrap ng-repeat="value in row | reduceString>{{value}}</td> </tr> </tbody> Directive: app.directive('createTable', function () { return { link: function (scope, element, attrs) { var contentTr = scope.$eval('"<tr ng-show="false"><td>test</td></tr>"'); $(contentTr).insertBefore(element); } } } ); Although I can append a new <tr> element to each iteration, I'm not able to get angular code executed after it's been added to the DOM (for example the ng-show inside the

Directive to upper case input fields

耗尽温柔 提交于 2019-11-30 15:57:14
I want to use a directive to transform all input data to uppercase. To achieve that, I create this custom directive : @Directive({ selector: '[appToUpperCase]' }) export class ToUpperCaseDirective { constructor() {} @HostListener('input', ['$event']) onKeyUp(event) { event.target['value'] = event.target['value'].toUpperCase(); } } And I use it like that : <form [formGroup]="formGroup" appToUpperCase> It works almost good exept that when I enter text in my field, the upper case transform is permormed but the focus is set at the end of the field...So when I edit a pre filled input, if I want to

Angular2 Can't bind to DIRECTIVE since it isn't a known property of element

半城伤御伤魂 提交于 2019-11-30 10:40:26
I generated new @Directive by Angular CLI, it was imported it to my app.module.ts import { ContenteditableModelDirective } from './directives/contenteditable-model.directive'; import { ChatWindowComponent } from './chat-window/chat-window.component'; @NgModule({ declarations: [ AppComponent, ContenteditableModelDirective, ChatWindowComponent, ... ], imports: [ ... ], ... }) and I try to use in my component (ChatWindowComponent) <p [appContenteditableModel] > Write message </p> even if within directive is only Angular CLI generated code: import { Directive } from '@angular/core'; @Directive({

Using @import in objective C in conjunction with __cplusplus

喜夏-厌秋 提交于 2019-11-30 09:15:00
When I try to compile an Objective C++ file (.mm) that is linked to a file that uses the new @import directive, I get some errors. Currently, my only solution is to replace the @import with the old #import directive. Is there any other solution so I can still use @import? Edit : According to the latest docs this should work now. See this . You have to use the -fcxx-modules flag instead of the -fmodules flag, but as the official documentation suggests - EXPERIMENTAL and VERY BROKEN . I didn't manage to get it working at all... In my opinion it's better to stick with #import and #include until

How to get FormControl instance from ControlValueAccessor

跟風遠走 提交于 2019-11-30 05:22:15
I've the following component: @Component({ selector: 'pc-radio-button', templateUrl: './radio-button.component.html', providers: [ {provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => FieldRadioButtonComponent), multi: true} ] }) export class RadioButtonComponent implements ControlValueAccessor { ... } I can assign and alter the value through these inputs: <pc-radio-button [formControl]="formControl"></pc-radio-button> <pc-radio-button [formControlName]="inputControlName"></pc-radio-button> However I need the component to have the direct access to the assigned formControl, as I need to

AngularJS - Formatting ng-model before template is rendered in custom directive

独自空忆成欢 提交于 2019-11-30 05:19:13
I am creating a custom directive in Angular JS. And I want to format the ng-model before the template renders. This is what I have so far: app.js app.directive('editInPlace', function() { return { require: 'ngModel', restrict: 'E', scope: { ngModel: '=' }, template: '<input type="text" ng-model="ngModel" my-date-picker disabled>' }; }); html <edit-in-place ng-model="unformattedDate"></edit-in-place> I want to format the unformattedDate value before it is entered in the ngModel of the template. Something like this: template: '<input type="text" ng-model="formatDate(ngModel)" my-date-picker

AngularJs - Calling Directive Method from Controller

我们两清 提交于 2019-11-30 03:50:23
原文链接: https://www.codeproject.com/Tips/863825/Angular-Calling-Directive-Method-from-Controller 10 Jan 2015 CPOL This tip will cover an uncommon issue in Angular – calling a directive method from a controller. Introduction This tip will cover an uncommon issue in Angular – calling a directive method from a controller. I’ve first encountered this issue when I worked with Angular and WinJS on an XBOX project. I needed to open the Settings popup on button click event, but this popup was placed in the directive. Normally I would expose a public method in the directive and call it from the