directive


AngularJS two-way data binding not working properly in directive

纵饮孤独 提交于 2020-01-24 00:29:08
问题 i am trying to implement radio-button list using ng-repeat. typeList.html <div ng-repeat="type in types" > <input type="radio" id={{type.id}} name="{{type.name}}" ng-model="result" ng-value="type.id" > {{type.name}} <div> Result {{result}} </div> //result is changing only in the row of clicked radio-button. It should change in every row.(two way data-binding). </div> Directive: angular.module('app').directive('myList',function(){ return{ restrict: 'A', scope: { types: '=', //here list is

How to inject a controller into a directive when unit-testing

左心房为你撑大大i 提交于 2020-01-22 10:33:16
问题 I want to test an AngularJS directive declared like this app.directive('myCustomer', function() { return { template: 'cust.html' controller: 'customerController' }; }); In the test I would like to inject (or override) the controller, so that I can test just the other parts of the directive (e.g. the template). The customerController can of course be tested separately. This way I get a clean separation of tests. I have tried overriding the controller by setting the controller property in the

How to inject a controller into a directive when unit-testing

社会主义新天地 提交于 2020-01-22 10:33:08
问题 I want to test an AngularJS directive declared like this app.directive('myCustomer', function() { return { template: 'cust.html' controller: 'customerController' }; }); In the test I would like to inject (or override) the controller, so that I can test just the other parts of the directive (e.g. the template). The customerController can of course be tested separately. This way I get a clean separation of tests. I have tried overriding the controller by setting the controller property in the

Prolog DCG set_prolog_flag double_quotes source code directive location matters; documentation?

北慕城南 提交于 2020-01-13 09:22:09
问题 I learned the hard way that with SWI-Prolog the location for the Prolog directive set_prolog_flag matters in a source code file. The only documentation I found of value about loading source code files with directives was in Loading Prolog source files A directive is an instruction to the compiler. Directives are used to set (predicate) properties (see section 4.15), set flags (see set_prolog_flag/2) and load files (this section). Directives are terms of the form :- <term>. Is there

AngularJS directive toggle menu preventing default for other directive

本小妞迷上赌 提交于 2020-01-13 06:02:12
问题 So I made a directive for a toggle (drop down) menu in AngularJS. I used the directive for multiple items within the page but I have a small problem. When one item is open and I click another one I want the previous one to close. The event.preventDefault and event.stopPropagation stops the event for the previous item and doesn't close it. Any ideas on how to fix this? Is there a way to perhaps only stop the event within the scope? app.directive('toggleMenu', function ($document) { return {

How to pass filter to a directive in AngularJS

五迷三道 提交于 2020-01-11 11:28:10
问题 I have a custom directive and I want to be able to pass a filter name to it. That filter will then be use in my template. Here is what I got so far: the directive: angular.module('forecastDirective', []) .directive('forecast', ['appConfig', function(appConfig) { return { templateUrl: appConfig.directivesRoot + 'templates/forecast.html', replace: true, scope: { weatherObject: "=", convertToDate: "&", filterTemp: "@", dateFormat: "@", }, } }]); The template: <div class="panel panel-default">

Angular2 triggering Host listeners on a button click

一个人想着一个人 提交于 2020-01-05 05:52:49
问题 I need to trigger Host listeners after a click of a certain button. The host listeners should then highlight any hovered element on page and listen to mouse clicks which would open a modal. Problem is that when I start listening for mouse clicks and do click, the modal sometimes doesn't open until I click the button that triggers the Host listeners. Also the highlighted elements get 'stuck' and stay highlighted after a mouse click trying to open a modal. Is it an asynchronous problem? Any

Angular2 triggering Host listeners on a button click

ε祈祈猫儿з 提交于 2020-01-05 05:52:07
问题 I need to trigger Host listeners after a click of a certain button. The host listeners should then highlight any hovered element on page and listen to mouse clicks which would open a modal. Problem is that when I start listening for mouse clicks and do click, the modal sometimes doesn't open until I click the button that triggers the Host listeners. Also the highlighted elements get 'stuck' and stay highlighted after a mouse click trying to open a modal. Is it an asynchronous problem? Any

AngularJS ng-model form driven by ng-repeat over UI model description data how to?

烂漫一生 提交于 2019-12-29 09:26:12
问题 The JSFiddle http://jsfiddle.net/vorburger/hyCTA/3/ illustrates a (working) "UI modeling" idea I had with AngularJS; note the form is not actually coded out in the HTML template, it's driven by uimodel JSON (which in turn describes how the datamodel is to be rendered/edited): <div ng-repeat="auimodel in uimodel"> <label>{{$index + 1}}. {{auimodel.label}}</label> <input ng-model="datamodel[auimodel.model]" type="{{auimodel.type}}" /> </div> Trouble is, as soon as my 'model' isn't a simple

Is there a way to both check a macro is defined and it equals a certain value at the same time

懵懂的女人 提交于 2019-12-29 06:39:29
问题 I regularly use object-like preprocessor macros as boolean flags in C code to turn on and off sections of code. For example #define DEBUG_PRINT 1 And then use it like #if(DEBUG_PRINT == 1) printf("%s", "Testing"); #endif However, it comes a problem if the header file that contains the #define is forgotten to be included in the source code. Since the macro is not declared, the preprocessor treats it as if it equals 0, and the #if statement never runs. When the header file is forgotten to be

工具导航Map