angularjs-directive

angular js two way binding contenteditable via scope attribute

断了今生、忘了曾经 提交于 2019-12-04 19:44:53
Is it not possible to set value from parent scope to contentEditable directive via isolated scope using two-way binding? Code here: http://jsfiddle.net/bharatwaj/3wTd3/5 HTML: <input ng-model="foo" /> <div contentEditable="true" binding-foo="foo" ng-model="input.name" title="Click to edit"></div> <pre>model = {{input.name}}</pre> JS: angular.module('form-example2', []).directive('contenteditable', function () { return { scope: { isolatedBindingFoo: '=bindingFoo' }, require: 'ngModel', link: function (scope, elm, attrs, ctrl) { console.log('isolatedBindingFoo value is ' + scope

Access AngularJs directive variable inside controller

和自甴很熟 提交于 2019-12-04 19:25:38
问题 I'm little bit new to Angularjs. What I want is access " $scope.myVar " variable inside ' myController ' controller. It would be great help if you can provide a solution. angular.module('myDirective', []) .controller('myController', ['$scope', function ($scope) { }]) .directive('myDirective', function () { return { scope: { myVar: '=' }, controller: function ($scope) { $scope.myVar = 'xyz'; alert($scope.myVar); } }; }); <html lang="en-US"> <script src="http://ajax.googleapis.com/ajax/libs

How to dynamically add a directive to all input elements in AngularJS across controllers & modules

China☆狼群 提交于 2019-12-04 19:12:40
I want to add a directive dynamically to all my textboxes in all my controllers & forms. I got a hack from here : How to dynamically add a directive to an input element in AngularJS but in my case: there are around 200+ forms spread across different controllers & modules & it will be very time consuming to add it everywhere. Is there an easier or more elegant way to do it ? Edit: What I want to do ? I want to remove all leading & trailing spaces entered by user in all input boxes. Angular can have multiple directives with the same name, and will apply them all to the element. Create another

Angularjs Button loading state directive with ng-disabled directive

大兔子大兔子 提交于 2019-12-04 18:49:32
I am trying to reconcile using the following directive for changing a button's loading state via bootstrap js plugin: .directive("btnLoading", function() { return function(scope, element, attrs) { scope.$watch(function() { return scope.$eval(attrs.btnLoading); }, function(loading) { if (loading) return element.button("loading"); element.button("reset"); }); }; This is working quite well as it controls the state of the button when necessary and adds the loading text as advertised. The issue I am running into is that when this directive is applied to a button as well as utilizing ng-disabled

ng-pluralize with translations Error:“TypeError”

半世苍凉 提交于 2019-12-04 18:24:03
Hi I am trying to localize the strings for pluralization in Angular. I am using ng-pluralize directive to handle pluralization and for localizations I am passing the strings to the directive at runtime based on user locale. But I am getting error "TypeError: Object # has no method 'one'" even if the $scope is loaded with translated strings.Following is my html code, <input class="input-text" type="number" ng-model="candyCount" ng-keypress="loadStrings()"/> <ng-pluralize count = "candyCount" when = "translateStrings" ></ng-pluralize> Javascript code myApp.controller(‘MyCtrl’,function($scope){

Fieldset and disabling all child inputs - Work around for IE

狂风中的少年 提交于 2019-12-04 18:14:58
问题 I have a fieldset that has a ui-view under it. Each view had lots of fields(a field is a directive that wraps an input) under it. It looks something like this: <fieldset ng-disabled='myCondition'> <div ui-view></div> // this changes with lot's of fields that look like <div field='text-box'></div> </fieldset> Now, this worked great, the fields get disabled on all browsers except IE . I've done some google and seen that ie doesn't support fieldset + disabled and I'm looking for a quick

bootstrap selectpicker not working with angularjs dynamic data load for dropdown

瘦欲@ 提交于 2019-12-04 18:14:52
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(); } } } <select id="special-size" bootselectpicker ng-model="items.selectSize" ng-options="size.key as size.value for

Content-Editable in the angular js

空扰寡人 提交于 2019-12-04 18:11:00
I have a table as shown below ╔═════╦═════╦═════╦═════╗ ║ A ║ B ║ C ║ D ║ ╠═════╬═════╬═════╬═════╣ ║ abc ║ pqr ║ XYZ ║ RSY ║ ╚═════╩═════╩═════╩═════╝ Now, In this table, I am using a content-editable of HTML5 for the column B . With this, I am able to edit the contents of the column B . Now, Here when I edit this, Is there any way through I will get to know which row has been edited and the value of a column An as well like, suppose I have edited pqr -> aaa then It should be like ╔═════╦═════╦═════╦═════╗ ║ A ║ B ║ C ║ D ║ ╠═════╬═════╬═════╬═════╣ ║ abc ║ aaa ║ XYZ ║ RSY ║ ╚═════╩═════╩════

AngularJS : Remove empty select option in angular ng-repeat

陌路散爱 提交于 2019-12-04 18:01:27
问题 I am using ng-repeat to render options with different value and text here, and also setting the default one.But again angular adds an empty undefined option. <select ng-model="newItem.financial_year_id" required style="min-width:180px;"> <option ng-repeat="financial in account_year" value="{{financial.id}}" ng-selected="financial.status=='Active'">{{financial.financial_year}}</option> </select> Now the active one is selected but the empty option still rendering. 回答1: Try ng-options instead:

Google map fitBounds not working

三世轮回 提交于 2019-12-04 17:39:30
I am creating a trip view using google map with angularjs directive. All works fine except the google map fitbound to a latitude longitude collection. I have tried all the way to use the fitbounds methods but failed. Thanks, Below is my code efforts. Directive: <div class="trip-google-map" trip-map="" mapid="2" latitude="22.998673" longitude="72.514346"></div> Directive Code: app.directive('tripMap', function ($compile) { return { controller: function ($scope, $location, mapService) { this.registerMap = function (myMap) { mapService.setTripMap(myMap); }; }, link: function (scope, elem, attrs,