angularjs-directive

Directive link function does not have access to the entire template DOM

旧时模样 提交于 2020-01-02 08:36:05
问题 I have a directive which has a template that recursively include a template. In my directive link function, I am unable to get the complete DOM with a selector. Here is my directive. Notice that my directive try to call dropdown() function on all .ui.dropdown divs constructed so nested dropdown will be activated. .directive("floatingDropdown", function() { return { restrict: 'E', templateUrl: "scripts/Ui/FloatingDropdown.html", replace: true, scope: { uiClass: '@', model: '=ngModel',

Angucomplete-alt: Remote-API-handler not working as expected

别来无恙 提交于 2020-01-02 07:36:34
问题 I'm using angucomplete-alt (https://github.com/ghiden/angucomplete-alt) in an AngularJS project, however I can't seem to make it work. I'm trying to build a really simple autocomplete form, like this: <angucomplete-alt pause="400" selected-object="obj" remote-api-handler="search" title-field="id" minlength="1" /> And my function is defined in the controller as such: $scope.search= function (userInputString, timeoutPromise) { return $timeout(function () { return [{ "id": "1" }, { "id": "2" },

How can I get my compiled array from ng-options in a custom directive?

廉价感情. 提交于 2020-01-02 06:38:13
问题 I have a custom directive which I am decorating a <select ng-options=""> with as such... <select custom ng-model="selected" ng-options="o for o in values"> with custom as my directive and values being a simple array. Here is my implementation... <select custom ng-model="selected" ng-options="o for o in values"> <option value selected>uhh?</option> </select> app.directive('custom', [function() { return { scope: {}, link: function(scope, elem, attrs) { // how can I get my array of values here?

Angular 1.5 Custom directive to Component

纵饮孤独 提交于 2020-01-02 05:56:12
问题 I've upgraded to Angular 1.5 which now supports the .component() helper method in the efforts to help users transition to AngularJs 2. Unfortunately there are not many tutorials out there on it. I have the following simplified custom directive and template URL. Can anyone help me write this in .component() form? By doing this I should get the basics of it and and should be able to use it for more complex directives. Thanks in advance. DIRECTIVE angular.module("formText", []) .directive(

Convert jquery plugin into directive angular

半城伤御伤魂 提交于 2020-01-02 04:07:12
问题 I'm trying to convert jQuery plugin into directive. Here is the library: Github. In the documentation there is an option : $(document).ready(function() { $("#datepicker").datepicker(); $("#datepickerbtn").click(function(event) { event.preventDefault(); $("#datepicker").focus(); }) }); Directive I've created : app.directive('dateP', function(){ return{ restrict:'A', require:'ngModel', link:function(scope, element, attr, ngModel){ $(element).datepicker(scope.$eval(attr.dateP)); console.log('hey

passing object to angularjs directive from the controller

北战南征 提交于 2020-01-02 02:21:10
问题 Trying to get my head around AngularJS directives. I need to pass a full object from my main controller to the directive. See the code below and jsfiddle: http://jsfiddle.net/graphicsxp/Z5MBf/4/ <body ng-app="myApp"> <div ng-controller="MandatCtrl"> <div person myPerson="mandat.person"></div> <span>{{mandat.rum}}</span> <span>{{mandat.person.firstname}}</span> </div> and the script: var myApp = angular.module("myApp", []); myApp.controller("MandatCtrl", function ($scope) { $scope.mandat = {

Passing arguments to ngChange event call from inside directive

孤人 提交于 2020-01-02 01:04:11
问题 I have a directive that accepts an ng-change attribute: <radio-buttons options="optionsList" ng-model="myModel" ng-change="myCallback($event)"></radio-buttons> I've defined a function in my controller, myCallback , that looks like this: $scope.myCallback = function(e) { console.log("Callback from controller"); console.log(e); } The following function select exists within my radioButton directive. I need to define when the ngChange callback is executed inside my directive in the select

AngularJS: ngInclude and dynamic URLs

最后都变了- 提交于 2020-01-02 01:00:08
问题 I'm using the ngInclude directive to load HTML fragments. Now I'm looking for the best way to pass a dynamic URL. I know I can create the URL with string concatenation: <ng-include src="'/foo/' + fooId + '/bar/' + barId + '/baz/' + bazId"></ng-include> In my eyes this is a bit ugly. ngHref and ngSrc for example, accept URLs containing {{}} markup. IMHO this syntax is much cleaner: <img ng-src="/foo/{{fooId}}/bar/{{barId}}/baz/{{bazId}}"/> <a ng-href="/foo/{{fooId}}/bar/{{barId}}/baz/{{bazId}}

Render AngularJS directive on $http loaded content

前提是你 提交于 2020-01-01 19:59:49
问题 I have a bit of a problem. I have a directive app.directive('a', function() { return { restrict: 'E', link: function(scope, elem, attrs) { elem.on('click', function(e){ e.preventDefault(); alert('Hyperlinks not allowed!'); }); } }; }); and a $http request for JSON containing the page content { "currentNodeName":"Page 1", "childrenNodes":[ {"id":"3","name":"Page 1-1"}, {"id":"4","name":"Page 1-2"}], "parentNode":null, "currentNodeContent":[ {"content":"<p>This is Page1. <a href=\"http:/

bootstrap selectpicker not working with angularjs dynamic data load for dropdown

微笑、不失礼 提交于 2020-01-01 19:53:10
问题 It is working for Static dropdown list, but when its applying for dynamic data load with angularjs the selectpicker has been applied, but data's are not loaded. if I removed this directive from dropdown then datas are loaded perfectly, what is the issue? I have tried more... Note : the method created using with class so, no issue in that bootselectpicker: function() { return { restrict: "A", require: "ngModel", link: function(scope, element, attrs, ctrl) { element.selectpicker(); } } }