angularjs-directive

Angular - Directive reflecting ngModel array

Deadly 提交于 2019-12-08 10:17:24
问题 This is piggy-backing a little off an earlier question. I have been trying to work with directives and data from a model/array My model looks something like this: $scope.testModel = { inputA:[1,2,3] }; Then I would have inputs for each. My directive is checking, on keyup, if the input is greater than a given number (10). If it is, then it sets it as 10. link: function(scope, element) { scope.$watch('ngModel',function(val){ element.val(scope.ngModel); }); element.bind("keyup", function(event)

how to add ng-include callback to multiple ng-include directives in angular js

六月ゝ 毕业季﹏ 提交于 2019-12-08 09:40:00
问题 I have my HTML like this <form ng-controller="testCtrl1"> <div ng-include="'test/views/navigationbar.html'"></div> <div ng-include="'test/views/processnav.html'"></div> <div ng-include="'test/views/leftprocesstabs.html'"></div> </div> </form> I want to write generalized method to check all my ng-include file are loaded. After loading all file i need to make a server call. Is there any way to check this in angular js? 回答1: use the onload of each template and increment a counter. if the form

how to empty reference object in angular js?

风流意气都作罢 提交于 2019-12-08 09:39:31
问题 I am trying to empty my reference object .But it is not deleting or removing my chart . I make two directive and communicate with shared service.But then I delete my reference object .it not deleted my chart ..on click of "delete" button i need to delete my chart .. is it possible ?because I take reference objects here is my code http://plnkr.co/edit/TzUlqoh4sYVjH3ADRTGL?p=preview angular.module('app',['header','chartm','hig']).controller('cntrl',function(){ }).service('sharedService'

Bind custom javascript event to angular

一笑奈何 提交于 2019-12-08 08:31:14
问题 I'm working on a mobile application where I have list with some items. This list can be pulled down to inititate a refresh of the list (I'm using iScroll4). I'm now trying to hook this event up to my angular controller so I can make an api call and update the model. The javascript is basically as follows: [..] //javascript code to detect the pulldown event function pullDownAction(){ //I want to update the scope here } Based on what I have read, I need to make an angular directive and call the

How to write an AngularJS directive that creates DOM elements that are other directives?

痞子三分冷 提交于 2019-12-08 08:14:50
问题 I'm writing some pretty complex DOM manipulations, which is sure to test my ability to write very complex directives. I have not come across any examples (I think anyway) that demonstrate what I'd like to do. Let's say I have a list of widgets, which can be of different types. These widgets need to be displayed within an <ul> element. Each type of widget can be different though, so the actual markup for each widget inside the <li> will drastically be different. If all I needed was standard

Angular: $resource update fire PUT request on second call only

筅森魡賤 提交于 2019-12-08 08:03:51
问题 I have a resource with a custom update method : angular.module('user.resources', ['ngResource']). factory('User', function($resource) { var User = $resource('/user/:id', {}, { update: { method: 'PUT' } }); User.prototype.update = function(cb) { console.log('foo'); return User.update({ id: this._id }, angular.extend({}, this, { _id: undefined }), cb); }; I'm passing this resource to a custom directive via scope: directive('avatarUpload', function($http) { return { restrict: 'E', scope: { model

Illegal use of ngTransclude directive in the template! when doing transclusion manually

北城以北 提交于 2019-12-08 08:00:01
问题 I preciously asked on SO if it was possible to transclude the inner contents of a directive twice in the directive template (clone it and insert it in two places in the template). A very helpful person helped me put this plunkr together. http://plnkr.co/edit/k2UB1o4CTHtZ1voS0OKN?p=preview It seems to work at first. The problem comes when I use any child element which uses transclusion itself. The error I get is... [ngTransclude:orphan] Illegal use of ngTransclude directive in the template! No

AngularJS - Pass dynamic object value and call function from Directive

我只是一个虾纸丫 提交于 2019-12-08 07:37:52
问题 Ctlr.js app.controller('myCtrl', function($scope) { $scope.data = { waterMarkImgPosition: [ {id: 'lowerRight', name: 'Lower Right'}, {id: 'lowerLeft', name: 'Lower Left'}, {id: 'upperRight', name: 'Upper Right'}, {id: 'upperLeft', name: 'Upper left'}, {id: 'center', name: 'Center'} ], selectedPosition: {id: 'upperRight', name: 'UpperRight'} //This sets the default value of the select in the ui }; $scope.watermarkPosition = $scope.data.selectedPosition.id; //pass default position for watermark

AngularJs radio buttons are connected when using ng-form with ng-repeat

三世轮回 提交于 2019-12-08 07:36:59
问题 See this plnkr http://plnkr.co/edit/WZHMuYY3y2wbI6UysvY6?p=preview When using a ng-form tag on an ng-repeat which contains a radio button group, the radio buttons are linked so if you check a radio button in one ng-repeat it will deselect in all the other ng-repeats. This puzzles me as the model of the ng-repeat is otherwise isolated from the other items. This is not only an issue when using ng-repeat. It also occurs when having multiple instances of a custom directive with isolated scope

How to set title attribute for option elements in a select bound to a model with AngularJs?

你说的曾经没有我的故事 提交于 2019-12-08 07:27:25
问题 I have a select element in my html bound to an ng-model. Something like this example: <select data-ng-model="accountType" data-ng-options="at.name for at in accountTypes"> </select> My accountTypes would look like this: accountTypes:[ { name:'Individual', value: 1, title: 'Individual Account'}, { name: 'Joint', value: 2, title: 'Joint Account'} ]; How can I achieve the final markup to look like this once the model is bound: <option value="1" title="Individual Account">Individual</option>