problem about directive-Collection of common programming errors
Willem Mulder
angularjs angularjs-directive directive
I’m trying to test a Directive in Angular, but I can’t get the corresponding template to work.The directive lists the templateUrl like sotemplateUrl: ‘directives/listview/view.html’Now when I write any unit-test, I getError: Unexpected request: GET directives/listview/view.htmlSo I have to use the $httpBackend and respond with something sensible like httpBackend.whenGET(‘directives/listview/view.html’).respond(“<div>som</div>”);But really I want to simply return the actual file, and
OMG Ponies
c# preprocessor directive
In C++ we can do this:struct { #if defined (BIGENDIAN)uint32_t h;uint32_t l; #elseuint32_t l;uint32_t h; #endif} dw;Now, in C# not so simple. I have a method to test for BigEndian but to define the struct at compile time, how can we get the same effect in C#? I was thinking that I can have classes like “BoardBig” and “BoardLittle” and use a factory to get the class I need based off of the IsBigEndian check. And for _WIN64 checks, I can have classes like “Position_64” and “Position_32” something
BalusC
jsp jstl directive
I would like to include a file depending on a request attribute value. ${theme} -> themeATo sum up. I would like something like this: <%@ include file=”../themes/${theme}/jsp/content/welcome.jsp”%>Any easy workaround?
Martin Reiner
delphi directive compiler-directives
I found this directive declared in Controls.pas (and also in other units) and I’ll be glad to know what does it mean.{$C PRELOAD}As far as I know $C means assertions control but what is the PRELOAD keyword ? Is it something like “assert me at preloading time” ?I found this in Delphi 2009Thank you
Luigi Giuseppe
java jsp include directive
I’m want to build a function that makes something like:void MyIncludeCompile(String TheFile) {“%><%@include file=”+TheFile+”%><%”; }I want to obtain an alternative to include directive building my own method or function.Something like:org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, TheFile, out, false);But, it’s applicable to something:void MyIncludeRun(String TheFile) {%><jsp:include page=”+TheFile+”/><%”; }In other words in translation time instea
yeeen
c# visual-studio directive
Can I write in code to set the variable to true or false depending on a button I pressed? See example below. If not, what other ways are there to achieve similar effects? Cos I have already marked the codes for different modes using directives and only want developers to have the option of switching the modes, but now I wish to give the user the option of switching btn the modes. The choice of the mode will only be given at the start of the program, and user is not allowed to switch the mode. To
miliu
angularjs directive plunker
I ran into this error in my project. To illustrate it, I created a Plunker at http://plnkr.co/edit/LBXeqA5zL2dH5Zjlu6h1. Actually, when you enter anything in search for box, there are two errors, one is “Error: 10 $digest() iterations reached. Aborting!” and the other “Uncaught Error: 10 $digest() iterations reached. Aborting!” and they seem to go together. How to fix it?
kelvo
javascript angularjs directive
i am trying to write a directive to generate pagination links using the concept used in a simplePagination the prev and next links are the only links being generated and clicking them generates an error:Uncaught SyntaxError: Unexpected token : here is the fiddle http://jsfiddle.net/kelvo/zZURe/Edit 1got the rest of the links to show but the bi-directional binding ‘=’ does not seem to work.here is the new fiddle http://jsfiddle.net/kelvo/zZURe/7/
Braulio
validation service angularjs directive
I have some doubts about AngularJS + Custom Validations, from what I have read and checked by myself:AngularJS provides great helpers for simple field validation (ng-require, …). The best way to implement a single field custom validation is via directive (not polluting the controller).My doubts come when we have custom business validations that impact on more than one filed. Let’s check the following simple scenario:We are editing a flight arrival status, fields: Status (landed / scheduled / d
Mark Rajcok
javascript jquery angularjs directive
I’m working on a directive for AngularJS that builds a taggable element and utilizes TagsInputHere’s a working fiddle: http://jsfiddle.net/mgLss/Not sure why but when I add that directive to my application IT works fine, but anything else below it running angular fails and I get this error message:Error: node is undefined compositeLinkFn@http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:3837 compositeLinkFn@http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js:3837 nodeLi
Aviran
twitter-bootstrap angularjs tooltip directive
I want to create a directive that shows Tooltip (from AngularJs Bootstrap UI) based on user is authorized or not.It does the job well and add the required attributes tooltip and tooltip-position but the tooltip doesn’t show up. If i compare the element generated by my code and element that has a tooltip as normal html, its identical except class=”ng-scope”, adding this class manually doesn’t help.Here is my directive code:proGamersApp.directive(‘registered’, [‘$rootScope’, ‘authService’, functio
Kassem
javascript angularjs angularjs-directive directive
This question is a follow-up to Array being reset to undefined after adding items to it. Please read it first to know what the Node object looks like.Anyway, so I got the tree data structure working fine. Every node has its children added to it properly. Now I need to render those on screen using AngularJS directives. I’m still fairly new to directives so I donno where I went wrong. Here’s what I’ve got so far:angular.module(‘hierarchy.directives’, []).directive(‘node’, function ($compile) {retu
mawo
javascript angularjs angular directive
I created a custom directive for the following widget attribute:Basically the directive just creates some template code and puts the html inside the widget-tag. Here’s the directive:skdApp.directive(“widget”, function() {return {restrict: ‘A’,template: htmlTemplate,link: function($scope, element, attri) {/** setup event handler and twitter bootstrap components here*/}}The htmlTemplate is basic html code which also uses custom directives (e.g. the <seal> tag):var htmlTemplate = ‘<div ng-
Gilad
angularjs expression directive ng-repeat
hya,i”m trying to do something like this <ul><li ng-repeat=”{{myRepeatExpression}}”>{{row.name}}</li> </ul>but because the ng-repeat logic is in the compile state of the directive it treats the {{myRepeatExpression}} as a normal string instead of a variable. which doesn’t work obviously.is there any workaround for that?
user2247790
angularjs undefined directive ng-repeat
The problem is that I have to manage a list of gum balls that is retrieved from a service. The directive I’ve created seems to work when I hardcode the elements in the HTML, but when I attempt to dynamically allocate the gum balls using a ng-repeat.HTML<div ng-controller=”GumballsCtrl”><h1>Working</h1> <ul><li ng-repeat=”gumball in Gumballs”><div class=”gumballColor{{gumball.color}}”>{{gumball.color}}</div></li></ul><h1>Problem – Expect
Gidon
angularjs autocomplete directive angular-http
I’m trying to write an autocomplete directive that fetches data from the server using an $http request (without using any external plugins). Currently it works only with static data. Now, I know that I need to insert my $http request into the source: of the directive, but I can’t find any good documentation on the subject.Http request – $http.post($scope.url, { “command”: “list category() names”}). success(function(data, status) {$scope.status = status;$scope.names = data; }).error(function(d
river6
jquery jquery-ui autocomplete angularjs directive
Recently I tried to write a AngularJS directive to use with Jquery UI autocomplete widget. The directive is used this way:<input type=”text” auto-comp ng-model=”lan” />It is supposed to function as as autocomplete widget, and stored the selected item to a model, $scope.lan.Finally I was successful, but find that I have to put a “div” tag wrapping the “input” tag, i.e., <div><input type=”text” auto-comp ng-model=”lang” /></div>Without the “div” wrapping, Chrome will repor
Voles
javascript binding angularjs directive
I’m trying to get an evaluated attribute from my custom directive, but I can’t find the right way of doing it.I’ve created this jsFiddle to elaborate.<div ng-controller=”MyCtrl”><input my-directive value=”123″><input my-directive value=”{{1+1}}”> </div>myApp.directive(‘myDirective’, function () {return function (scope, element, attr) {element.val(“value = “+attr.value);} });What am I missing?
C M
object angularjs controller initialization directive
I’ve have run into an issue with object initialization differing whether the code is in a controller vs a directive link function. In the example code below, the “this” parameter being passed in the prop: new Object(this) is a legit Object constructor when the code is run in the controller but is undefined when run in the directive. Why the difference in execution of the same code?myapp.directive(“myDir”,function() {var myDir = {link: function(scope,element,attrs){var obj;obj = new Object({
Maarten
unit-testing angularjs directive
I’m using the following code in a directive to place a tool tipvar bodyoffset = document.querySelector(“.smallcontainer-content”).getBoundingClientRect(); var width = elm.width(); if(bodyoffset != undefined){var tooltipDiv = document.querySelector(“.tooltip”);angular.element(tooltipDiv).css(“top”, offset.top-bodyoffset.top+”px”);angular.element(tooltipDiv).css(“left”, offset.left-bodyoffset.left+width+5+”px”); }This doesn’t work in a unit test as the div the class ‘smallcontainer’ is on doesn’t
Vlad
angularjs attributes scope directive
I have this fiddleangular.module(‘mainApp’, []).directive(‘list’, function factory() {return {restrict: ‘E’,scope: {size: ‘=’,listWidth: ‘@’},replace: true,template: ‘<ul class=”syn-list”><li ng-repeat=”item in items”>{{item}}</li></ul>’,link: function(scope, element, attrs) {scope.items = [‘item 1’, ‘item 2’, ‘item 3’];$(‘#p1’).html(scope.size + ‘ – ‘ + attrs.size + ‘ :: ‘ + scope.listWidth + ‘ – ‘ + attrs.listWidth);setTimeout(function() {$(‘#p2’).html(scope.size + ‘ –
Julio
angularjs attributes directive
I would like to create a directive and use the argument in my controller:<body ng-app=”tstApp”><navigationbar tst=”hello”></navigationbar> </body>For this I create a directive and its controller:navigationBar = {}; navigationBar.directives = {}; navigationBar.controllers = {};navigationBar.directives.navigationbar = function () {return {restrict: ‘E’,scope: {t1: ‘@tst’,t2: ‘=tst’,t3: ‘&tst’},templateUrl: “common/navigation_bar/navigation_bar.tpl.html”,controller: “Nav
I159
javascript angularjs scope directive
I try to use directive to create and append several tags to a div. I just checked what can I got in the directive:module.directive(‘createControl’, function(){return function(scope, element, attrs){ console.log(attrs.createControl); // undefined } }) <div class=”control-group” ng-repeat=”(k, v) in selectedControls”><div create-control=”{{ v.type }}”></div> </div>In attrs I have this
Freewind
sortable angularjs directive
I’m trying to define a directive sortable which wraps jqueryui’s sortable plugin.The angular code is:module.directive(‘sortable’, function () {return function (scope, element, attrs) {var startIndex, endIndex;$(element).sortable({start:function (event, ui) {startIndex = ui.item.index();},stop:function (event, ui) {endIndex = ui.item.index();if(attrs.onStop) {scope.$apply(attrs.onStop, startIndex, endIndex);}}}).disableSelection();}; });The html code is:<div ng-controller=”MyCtrl”><ol so
Reddy Sijaya
angularjs directive
How to bind scope from attrs.$observe?<test func=”hohoho”></test> app.directive(‘test’, function(){return {restrict: ‘E’, scope: { parentFunc: ‘@func’}, link: function(scope, element, attrs) {var func = ”;attrs.$observe(‘func’, function(val) {func = val;console.log(func);})console.log(‘end’);console.log(func);console.log(scope.parentFunc);});}}; });when i run, it will printend undefined undefined(an empty string) hohohowhy i get undefined when i print func and parentFunc?
user1017413
javascript angularjs directive
I’m working on a landing page that is written largely with Angular JS 1.0.2. Upgrading to a later version may not be in the cards, at least not right away. It’s working fine, but we’re trying to do a bit of optimization. For a bit of background, we have a number of directives set up for various modal windows and other custom elements on the page. These use tempateUrl parameters and grab them from separate html files which contain all of the necessary HTML. Quick and dirty example as there’s way
iBlue
javascript angularjs angularjs-directive directive
Here is my angular js app with html code<html> <head><title></title><script src=”Scripts/jquery-1.4.1.js” type=”text/javascript”></script><script src=”Scripts/angular.min.js” type=”text/javascript”></script><script type=”text/javascript” language=”javascript”>angular.module(“demo”, []).controller(‘DemoController’, function ($scope) {$scope.user = {dateOfBirth: new Date(1970, 0, 1)}});</script> </head> <body><div ng-app=”d
Community
delphi warnings directive
I have a function that gives me the following warning:[DCC Warning] filename.pas(6939): W1035 Return value of function ‘function’ might be undefinedThe function, however, is clean, small, and does have a known, expected, return value. The first statement in the function is:Result := ”;and there is no local variable or parameter called Result either.Is there any kind of pragma-like directive I can surround this method with to remove this warning? This is Delphi 2007.Unfortunately, the help syste
Leo Selig
angularjs dependency-injection url-routing directive
I am currently trying to get in touch with AngularJS. Since I plan to build a rather complex web application I searched for an alternative to the ngView/$routeProvider combination to be found in the ng docs as I find them quite dissatisfying for a complex application with several navigation levels. So what I tried is to write a custom directive called ngRoute that could be used like this:<div ng-route=”users”><div ng-route=”:id”></div><div ng-route></div><!– def
TheFrancisOne
android android-ndk preprocessor directive
I have an Android project, using Android NDK.In file Application.mk, I use a custom directive named MYDIRECTIVE :APP_CFLAGS := -DMYDIRECTIVE=TESTAnd in .cpp file, I would like test its value :#ifdef MYDIRECTIVE #if MYDIRECTIVE == ‘TEST’ /* do some stuff */ #else #error MYDIRECTIVE is unknown #endif #endifAnd the issue is that I get MYDIRECTIVE is unknown message.When I compile with V=1 option, I see directive in compilation :-MYDIRECTIVE=TESTI tried test with ‘TEST’, with TEST, with “TEST”, and
Web site is in building