angularjs-directive

Datepicker-popup formatting not working when value set initially in scope

旧街凉风 提交于 2019-12-08 15:26:44
问题 I am using the Angular UI bootstrap date picker popup using this custom directive on Plunker (http://plnkr.co/edit/053VJYm1MpZUiKwFTfrT?p=preview): //Module var userModule = angular.module("userModule",['ui.bootstrap']); //Controller userModule.controller("sampleController", ['$scope', function ($scope) { $scope.minDate = new Date(); }]); //Directive code userModule.directive('datePicker', [function (dateFilter) { return { restrict: 'E', require: 'ngModel', scope: { ngModel: '=', ngReadonly:

AngularJS directive runs before element is fully loaded

▼魔方 西西 提交于 2019-12-08 15:13:16
问题 I have a directive attached to a dynamically generated <table> element inside a template. The directive manipulates the DOM of that table inside a link function. The problem is that the directive runs before the table is rendered (by evaluating ng-repeat directives) - the table is empty then. Question How can I make sure that the directive is ran after the table has been fully rendered? <table directive-name> <tr ng-repeat="..."> <td ng-repeat="..."></td> </tr> </table> module.directive(

Directive inner content with isolated and non-isolated scopes

前提是你 提交于 2019-12-08 14:42:07
问题 I found quite a strange behaviour of scope:true type for inner content of a directive: <body ng-init="x=10"> <mydir> {{x}} </mydir> </body> so {{x}} is inner content, and directive definition is: .directive('mydir', function() { return { scope: {}, link: function(scope){ scope.x = 5; } }; }); When we define scope as isolated ( scope:{} ), it outputs {{x}} as 10, so uses outer scope. But when we create new scope for the directive( scope:true ), it will use it for inner content and output 5. So

Showing unique dropdown options in Angularjs

混江龙づ霸主 提交于 2019-12-08 13:50:35
问题 I have a following drop down which is working fine <select class="form-control" ng-model="cc.id"> <option value="">Chose Id</option> <option ng-repeat="account in accounts |unique:'id'" value="{{account.id}}">{{name.id}}</option> </select> It gives me following options in the dropdown 101 101 119 120 121 121 While it should be only showing the unique id in options as... 101 119 120 121 Accounts consists of jason array of Account which has act_id (primary key) id fname lname location Can you

How to transfer data between controllers

感情迁移 提交于 2019-12-08 13:17:16
问题 I am trying to transfer data between controllers. So this is my first controller that fetches data first when page loads using http- function GetController($scope, $http) { $http.defaults.useXDomain = true; $http({ method: 'POST', url: serviceUrl + '/GetProductsByCategoryOrName', headers: { 'Authorization': apiKey }, data: { "query": "grocery", "categoryId": "976759", "pageIndex": 0, "sortDirection": "asc" } }).then(function successCallback(response) { $scope.products = response.data; }).then

Why a “preLink” function is used in angular directive `ngForm`, instead of regular “postLink” function?

允我心安 提交于 2019-12-08 12:41:57
问题 Inside angular.js, in ngForm (form) directive definition, compile function returns only a preLink function. Why it should be preLink instead of common postLink ? The following code is from angular.js master branch: var formDirective = { name: 'form', restrict: isNgForm ? 'EAC' : 'E', controller: FormController, compile: function ngFormCompile(formElement) { // Setup initial state of the control formElement.addClass(PRISTINE_CLASS).addClass(VALID_CLASS); return { pre: function ngFormPreLink

ui-grid custom directive height not getting updated when i change the data

我的未来我决定 提交于 2019-12-08 11:33:42
问题 I have a UI-grid Custom Directive and I am changing the height of grid with a condition that if it has more than 10 rows I am fixing the height, this is the following code scope.gridOptions.data = scope.data; if (scope.data.length > 10) { scope.gridOptions.minRowsToShow = 10; } else { scope.gridOptions.minRowsToShow = scope.data.length; } scope.gridOptions.virtualizationThreshold =scope.gridOptions.minRowsToShow; by default its working fine but when I change the data the height is not

How to get the form data when the form is in a directive in Angular?

女生的网名这么多〃 提交于 2019-12-08 10:49:04
问题 I have this this template: <div class="modal" id="popupModal" tabindex="-1" role="dialog" aria-labelledby="createBuildingLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title" id="createBuildingLabel">{{ title }}</h4> </div> <form data-ng-submit="submit()"> <div class="modal-body" data-ng-transclude> </div> <div class="modal

How to use jsTree events with AngularJS

断了今生、忘了曾经 提交于 2019-12-08 10:47:08
问题 I load my tree successfully using a directive in AngularJS .Now i want to add events (here select node) in my tree, so i did like this. but i can't see my alert . My code: app.directive('jstree', function() { return { restrict: 'A', scope: { jstree: '=' }, link: function(scope, element, attrs) { scope.$watch('jstree', function() { $(element).jstree({ "json_data" :{ "data":scope.jstree.data }, "themes" : { "theme" : "classic", "dots" : true, "icons" : true }, "plugins" : [ "themes", "json_data

Create a list without ngRepeat

有些话、适合烂在心里 提交于 2019-12-08 10:28:27
问题 I would like to create a directive, that does not need ngRepeat, because there is some additional functionality on the directive, that doesn't play good with ngRrepeat. This is my directive with ng-repeat: <div> <ul> <li ng-repeat="item in items track by $index" ng-class="attrs.itemTheme" data-item="{{ item[attrs.itemId]}}"> <div ng-include="attrs.tpl"></div> </li> </ul> </div> attrs.tpl, nt-dimension is another directive, that uses the items values from ngRepeat: <script type="text/ng