angularjs-directive

Why is the post link function executed before the transcluded child link functions?

你。 提交于 2019-12-31 14:46:14
问题 The timing of (pre/post)link functions in AngularJS are well defined in the documentation Pre-linking function Executed before the child elements are linked. Not safe to do DOM transformation since the compiler linking function will fail to locate the correct elements for linking. Post-linking function Executed after the child elements are linked . It is safe to do DOM transformation in the post-linking function. and this blog post clearly illustrates this expected order. But this order does

Can AngularJS directive pre-link and post-link functions be customized?

拈花ヽ惹草 提交于 2019-12-31 10:42:26
问题 I have seen many references to AngularJS pre- and post-link functions in literature about AngularJS. I am not sure however whether these can be customized or are internal to the framework. In other words, as an AngularJS developper, can I provide my own pre and post link functions to my custom directives? 回答1: Yes you can, as per @Mikke's answer. To sum up, there are four ways to declare linking functions: From within compile specifying both preLink and postLink functions explicitly: compile:

ng-select with an object and its properties in angularjs

☆樱花仙子☆ 提交于 2019-12-31 10:41:59
问题 I have been trying to figure out how to use an array if objects as the key values for an ng-select directive this is the data I want to use $scope.selectValues [ {name: "Options 1", value: "11"}, {name: "Options 2", value: "22"} {name: "Options 3", value: "33"} ]; and I want the output to be <select> <option value="11">Options 1</option> <option value="22">Options 2</option> <option value="33">Options 3</option> </select> Can anyone explain how to do this ? and show a an example of the

AngularJS form validation directive for showing input errors

守給你的承諾、 提交于 2019-12-31 09:04:04
问题 I need to create a validation directive for showing all input errors for each input automatically. This validation directive should show all errors at current moment and list of errors should be updated automatically while user is typing. I need to show all errors for input if input is dirty, not empty and invalid. I need to add all errors into html element near this input element. For example if input have type="email" and ng-minlength="5" and user typed 'abc' I need to show such errors near

Directive that run after ng-repeat

心已入冬 提交于 2019-12-31 07:15:49
问题 I have similar problem with this one Calling a function when ng-repeat has finished but I have directive and ng-repeat inside. <my-dropdown> <li ng-repeat="item in items"><a>{{item.text}}</a></li> </my-dropdown> In my dropdown I have ng-transclude in two places (one for a list and one for caption) and I need to add class ng-hide to all items except one using jQuery. So I need to have the code that will run after ng-repeat. I've try to set priority in my directive to 2000 or 0 (ngRepeat have

trying to add loading wheel using angular when i make ajax call?

我的未来我决定 提交于 2019-12-31 07:04:09
问题 I am trying to implement loading wheel directive when we make ajax call so during the response time i want to display loading wheen, With below code i do not see any error neither the loading wheel. Is there any better way to implement loading wheel using angularJs ? or What is implemented wrong in below code ? main.html <loading></loading> <ul style="list-style: none;"> <li ng-repeat="message in event | limitTo:1000" ng-class="{lastItem: $last}"><span>{{message.value}}</span></li> </ul>

script not running in templateurl

一个人想着一个人 提交于 2019-12-31 03:16:11
问题 This is my angular js file test.js file: var app = angular.module("angleapp", []) .controller('MainController', ['$scope', function ($scope) { $scope.test = "hi all" }]) .directive('programlisting', function () { return { restrict: 'E', scope: { }, templateUrl: '/directives/test.html' }; }); test.html file: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript"> alert("stop"); </script> </head> <body> hi how are you </body> </html> This is my index

Let inner directives run before outer directives angularjs

坚强是说给别人听的谎言 提交于 2019-12-31 03:01:16
问题 I have the following html: <div nag-tabs="tabsOptions"> <ul class="tabs"> <li ng-repeat="tab in tabs">{{ tab }}</li> </ul> <div class="tab_content"> <div ng-repeat="tabContent in tabsContent">{{ tabContent }}</div> </div> </div> The issue that I am having is that the tabs directive is running before the the ng-repeat directive. Is there any way to get the tabs directive to run after all the directives that encompasses the content of the nag-tab directive run (ng-repeat or whatever else might

AngularJS Directive templateUrl returns 400 though file URL loads

余生颓废 提交于 2019-12-30 18:47:13
问题 I have a basic directive in a MVC 5 Layout Page with a directive for searching. My problem is that the templateUrl cannot be loaded (400 error). If I enter the URL directly into the browser, I can load the html page without difficulty or error. I cannot find out why the AJAX call to load the page is failing. Chrome Debugger This is the HTML page loading in Chrome app.js (function() { var app = angular.module("mainApp"); app.directive("basicSearch", function() { return { templateUrl: 'app

AngularJS unit test for keypress event

浪尽此生 提交于 2019-12-30 11:30:06
问题 I set up a directive that binds a function for the keydown and keypress events. The directive sets the focus for an input on a form when a shortcut key is entered. <input type="text" id=txtField1" focus-key="a" /> <input type="text" id=txtField2" focus-key="b" /> <input type="text" id=txtField3" focus-key="c" /> Is it possible to trigger the keypress event for unit testing my directives? Thanks in advance for your help. 回答1: You can use jQuery with AngularJS, and you can do this fairly easily