angularjs-directive

angular how to define multiple controllers

好久不见. 提交于 2019-12-11 00:46:53
问题 i have code like this angular.module('mywidget', ['$scope']).controller('TestController', testController); I want to add another controller to it ..say ...controller("Test2Controller",Test2Controller) just wanted to know how we can achieve this ? 回答1: You can var myApp = angular.module('mywidget', ['$scope']); myApp.controller('TestController', testController); myApp.controller('Test2Controller', test2Controller); 来源: https://stackoverflow.com/questions/18100755/angular-how-to-define-multiple

How to delay the google autoComplete function to save credit

拟墨画扇 提交于 2019-12-11 00:44:05
问题 As you know every time when we type the google map autoComplete will fire, I want to set a delay function for this, such as 250ms,so give user more time to type and also save the credits. I try to add $timeout, but looks like it didn't work for me. Would you please take look at this for me? Thanks advance. Html: <input name="google_places_ac" type="text" class="google_places_ac input-block-level" ng-model="address" placeholder="Please enter a location" ng-blur="updateMap()"/> directive: link:

calling an angularjs attribute directive from inside an ng-repeat

…衆ロ難τιáo~ 提交于 2019-12-11 00:12:18
问题 I have a collection of table column objects that I am iterating over using ng-repeat. I am building the table dynamically based on the columns the user wants to see. Each TH tag calls a "sortable" directive like this... <th sortable collection="myCollection" sortcolumn="sortcolname">Heading</th> this is fine when the values for the custom attributes are hard-coded in (as above). But, in my code I am getting the values from the object in the collection like this.... <th ng-repeat="col in cols"

AngularJS - ngRepeat is applied double times when $compile the element's attributes

不想你离开。 提交于 2019-12-10 23:50:35
问题 I want this $scope.name = 'Angular'; $scope.list = ['foo: {{name}}', 'bar: {{name}}']; <div ng-repeat="template in list" compile="template"></div> to be <div real="foo: Angular"></div> <div real="bar: Angular"></div> So i use $compile: $compileProvider.directive('compile', function ($compile) { return function (scope, element, attrs) { scope.$watch( function (scope) { return scope.$eval(attrs.compile); }, function (value) { //element.html(value); //$compile(element.contents())(scope); element

Angular.js - ngModel value is undefined when ng-pattern is set in directive

只谈情不闲聊 提交于 2019-12-10 23:47:20
问题 something similar may have been answered (ng-pattern + ng-change) but all responses were unable to fix this issue. I have two imbricated directives for creating a form input, a parent directive to control name, label, validator etc. and a child directive to set pattern and input type specific stuff. However, when setting a pattern, the value on my model is set to undefined when ng-pattern return false. Directives: <input-wrapper ng-model="vm.customer.phone" name="phone" label="Phone number">

Angular JS callback after ng-repeat is completed dynamically

巧了我就是萌 提交于 2019-12-10 23:07:57
问题 There are tons of posts showing how to have callback functions based on a directive so that when an ng-repeat function is finished you can wait and then call a function. For example here is my example. <div ng-repeat="Object in Objects" class="objectClass" on-finish-render>{{Object.Overlay}</div> Then when it is completed the following calls my function .directive('onFinishRender', function ($timeout) { return { restrict: 'A', link: function (scope, element, attr) { if (scope.$last === true)

Change AngularJS ngTrim Behavior

房东的猫 提交于 2019-12-10 23:07:39
问题 I am using AngularJS version 1.5.6. I have a large application with lots of text areas and text inputs. I discovered a bug today caused by the default AngularJS behavior of trimming input for text type inputs. I would like to change this behavior from trimming by default to not trimming by default. Is there an easy way to do this rather than to go through hundreds of textareas and text inputs in my application. (perhaps globally or writing my own directive?) Here is the documentation page

Angular app is not defined when adding a custom filter outside of function

北城余情 提交于 2019-12-10 22:55:42
问题 Trying to follow some examples, but I get app is not defined app.js (function () { "use strict"; var app = angular.module("deviceManagement",['angularUtils.directives.dirPagination']); }()); So I have HOPING to be able to use or attach to "app" I have a controller js file (function () { "use strict"; angular .module("deviceManagement") .controller("DeviceListCtrl", ProductListCtrl); function ProductListCtrl($http, $scope) { var vm = this; vm.devices = []; deviceList(); function deviceList() {

AngularJS event-based communication through isolate scope

妖精的绣舞 提交于 2019-12-10 21:54:52
问题 In AngularJS, how can one directive use event-based communication ( $emit , $broadcast and $on ) to communicate with another directive which has an isolate scope? I've created two directives, and when the isolate scope is removed from the second directive, the first directive is able to use emit to successfully communicate with the second. However, when the isolate scope is added back to the second, communication breaks down. var app = angular.module('myApp', []); app.directive("firstDir",

How to dynamically change the URL in Select2 using AJAX?

纵饮孤独 提交于 2019-12-10 21:53:41
问题 I am using ui-select2 in angularjs for remote data access. I am having a drop down, based on the value chosen in dropdown the URL present in the ajax call should change dynamically , so that I can get the data from that particular URL. Is it possible to change the URL dynamically based on the value present in the dropdown? 回答1: I've resolved this problem using function in ajax property: ajax: { url: function () { return '/product/' +$scope.campaign.advertiser + '/tags/'; }, ... } 来源: https:/