angularjs-directive

How to bind View Date to model milliseconds with Angularjs

家住魔仙堡 提交于 2019-12-11 03:56:54
问题 I want to bind an input of type Date on the view to a milliseconds property in the model with Angularjs. For example : the user set "09/23/2014" into the field and angularjs automatically set "1411423200000" into the model property binding with the input. I don't find any directive or filter to do that. Thanks for your help. UPDATE to detail my question. Is there a "native" way in Angularjs to intercept model to view AND view to model and convert my data ? 回答1: You can use ng-change https:/

Adding directive inside the directive programatically

妖精的绣舞 提交于 2019-12-11 03:56:52
问题 I want to append another instance of my directive into the parent directive but i can't use $apply to recompile my directive. I think i miss something here somewhere :) My HTML Code <div ng-app="TestApp"> <div ng-controller="TestCtrl"> <input ng-model="NewData" /> <button ng-click="AddNewData($event)">Add New</button> <br /><br /> <div test-collector="testColScope" id="testCol"> <div test-data="" xx-value="Mouse" xx-href="https://fb.com"></div> <div test-data="" xx-value="Keyboard" xx-href=

AngularJS : isolated scope + two-way binding + ng-repeat not working

大憨熊 提交于 2019-12-11 03:55:53
问题 the ng-repeat outputs nothing. in the link function, i can see $scope.clients is an array. if i remove the isolate scope, and use the parent scope, the ng-repeat works. html with directive "clients". <div container ng-cloak ng-app="summaryReportApp" ng-controller="summaryReportController as summaryReport"> <fieldset clients="summaryReport.clients"> <legend>Clients</legend> <div align="left"> <div ng-repeat="client in clients track by $index"> {{client}} </div> </div> </fieldset> </div>

How to create a angular input directive that works with form validation

笑着哭i 提交于 2019-12-11 03:43:46
问题 How do I create an angular directive that adds a input in a form but also works with form validation. For instance the following directive creates a text input: var template = '\ <div class="control-group" ng-class="{ \'error\': {{formName}}[\'{{fieldName}}\'].$invalid}">\ <label for="{{formName}}-{{fieldName}} class="control-label">{{label}}</label>\ <div class="controls">\ <input id="{{formName}}-{{fieldName}}" name="{{fieldName}}" type="text" ng-model="model" />\ </div>\ </div>\ '; angular

Directive: Get attr scope-value in the templateUrl function

对着背影说爱祢 提交于 2019-12-11 03:39:16
问题 This is the directive that I wanna build: module.directive('templater', function () { return { restrict: 'A', replace: true, templateUrl: function (element, attrs) { return attrs.templater; } }; }); but, as you may know, in this HTML: <div ng-repeat="item in items" templater="item.template"> </div> accessing attrs.templater simply gives item.template instead of the actual template url string. How do you access the data inside attrs.templater without going inside the linking function? I want

AngularJS: show hide elements based on mouse events

独自空忆成欢 提交于 2019-12-11 03:38:43
问题 Here is an example - http://plnkr.co/edit/iwvjJcUurUW2AvkDArfz?p=preview I would like the delete button to show up only when mouse hovers on the row and perform some function delete(name), by passing the name How can I achieve this? P.S I am new to Angular world 回答1: This can be quickly solved with CSS, no need to bring JS or Angular. Just using basic CSS would be in my opinion better solution. Add the following to your stylesheet: <style> tr i.icon-minus-sign { display: none; } tr:hover i

Need explanation on a angular direcive load

半腔热情 提交于 2019-12-11 03:37:39
问题 I just want to understand why in the following jsFiddle 'here is a lo' is printed three times. http://jsfiddle.net/wg385a1h/5/ $scope.getLog = function () { console.log('here is a log'); } Can someone explain me why ? What should I change to have only one log "here is a log" (that's what I would like this fiddle do). Thanks a lot. 回答1: Angular uses digest cycles/iterations to determine when state has changed and needs to update the UI. If it finds any change on one of it's cycles, it keeps

AngularJS : $watch within directive is not working when $rootScope value is changed

此生再无相见时 提交于 2019-12-11 03:37:20
问题 I have created an application is angularjs in which i am having a directive, i am ahving a watch within the directive to trigger some methods within the directive when there is a change in $rootScope variable, but the problem is when the $rootScope.name value is changed the watch which is within the directive is not working My code is as given below Working Demo var module = angular.module('myapp', []); module.controller("TreeCtrl", function($scope, $rootScope) { $scope.treeFamily = { name :

ngGrid injection into ng-app failed

人盡茶涼 提交于 2019-12-11 03:36:58
问题 Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to: Error: [$injector:modulerr] Failed to instantiate module ngGrid due to: Error: [$injector:nomod] Module 'ngGrid' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. Above is the error message I received. I have loaded the ng-grid script AFTER angularjs, jquery. I injected it into app like this: var

ng-repeat changing sort order on all items when new item added to model

ぃ、小莉子 提交于 2019-12-11 03:35:52
问题 I created a "tessellate" directive that lets you wrap a number of divs. <tessellate columns="4"> <div class="thumbnail" ng-repeat="item in items track by item.id"> {{item.Name}}<br /> {{item.Summary}} </div> </tessellate> It takes one div at a time and appends it to the shortest of the specified number of columns to create a tessellation/mosaic effect. See the plunkr here: http://plnkr.co/edit/ur0bVCFRSz1UbRHeLjz8?p=preview The problem is that when the model changes, the ng-repeat uses the