angularjs-directive

How to call an application controller method from angular js directive

可紊 提交于 2019-12-14 03:25:15
问题 Hi I want to make a validation directive. It basically will call a remote validation on the server. I would expect something like this: <input type="text" id="nome" required ng-model="client.context" available="checkAvailableContexts"> and that should call a method on my ClientController like this: $scope.checkAvailableContexts = function(contexto, callbacks) { service.checkContextAvailability(contexto, callbacks); } and this is my service method: this.checkContextAvailability = function

why contend show multiple time in angular while using ajax call?

£可爱£侵袭症+ 提交于 2019-12-14 03:22:43
问题 I have two problem in my demo .I am making a pop over .I should open on icon click(here is used star icon).when i click star icon I am able to see pop up screen as I want but problem is that when I click another icon /star icon it open another pop over without closing the first one pop over.I need to display pop over one at time.. 1 ) can we show pop over one at one time .it show only one pop over at one time. 2)when I include in my plunker (tooltip.js and pop over plugin).It show the contend

How to pass a data object to a dynamically created directive? (fiddle)

允我心安 提交于 2019-12-14 02:29:12
问题 What I want to do is pretty simple, here is a fiddle to illustrate what I would like to achieve: code here: http://jsfiddle.net/vxpc1dry/ Basically on data fetch success I want to pass the returned response data object to a dynamically compiled directive, only the data object seems to be undefined not matter what :( Any idea what I'm doing wrong? thanks a lot! 回答1: angular.element(document.getElementById('dirContainer')).append($compile("<my-dynamic-directive name='data.name' data='data'></my

Angularjs: Listen to model change in a directive

北慕城南 提交于 2019-12-14 00:43:05
问题 I'm trying to find out how I can listen to when the model is updated within an directive. eventEditor.directive('myAmount',function(){ return { restrict: 'A', link: function(scope, elem, attrs) { scope.$watch(attr['ngModel'], function (v) { console.log('value changed, new value is: ' + v); }); } } } }; }); The directive is called within ng-repeat as <div ng-repeat="ticket in tickets"> <input my-amount ng-model="ticket.price"></input> </div> Very happy for any help. I don't understand how the

Recursive custom directives using ngRepeat

北慕城南 提交于 2019-12-14 00:19:15
问题 I'm trying to create a treeview using AngularJS. Here's my code: module.directive('treeview', function () { return { restrict: 'E', templateUrl: "/templates/ui/controls/treeview.htm", replace: true, transclude: true, scope: {}, link: function (scope, element, attrs) { console.log("treeview directive loaded"); }, controller: function ($scope, $rootScope) { $rootScope.depth = 0; $scope.items = [ { text: "face" }, { text: "palm" }, { text: "cake", childitems: [ { text: "1 face" }, { text: "1

Do angular conditions work the same way as pure javascript? [duplicate]

别说谁变了你拦得住时间么 提交于 2019-12-13 22:57:25
问题 This question already has answers here : Which equals operator (== vs ===) should be used in JavaScript comparisons? (49 answers) Closed 4 years ago . I wonder if there is the same difference between identity === and equality == operators in angular directives like in pure javascript? For example is ng-if="value === 'foo' better than ng-if="value == 'foo' What I checked is that ng-if="true == 1 passes but ng-if="true === 1 doesn't, so it looks like it works the same way like pure js. On the

Angularjs scope.$apply in directive's on scroll listener

蹲街弑〆低调 提交于 2019-12-13 21:27:06
问题 I am using the following directive to find out if the user has scrolled to the bottom of the page - 150px and set a scope variable which is being listened to and the following page is loaded. It works fine. My concern is that scope.$apply() is being called multiple times. I need to call $apply() for the directive to work but i am not sure if calling it multiple times can cause problems. Any thoughts? Thank you. myMod.directive('scrollDetection', function () { return { restrict: 'AE', link:

AngularJS list of toggle buttons directive

时光毁灭记忆、已成空白 提交于 2019-12-13 21:23:28
问题 I wanted to create a reusable component of toggles/switches list. I've already made a <toggle> directive, and now want a <toggle-list> containing multiple <toggle> 's. <toggle-list> <toggle value="A">Toggle A</toggle> <toggle value="B">Toggle B</toggle> </toggle-list> . app.directive("toggle", function(){ return { scope: {}, restrict: "E", transclude:true, templateUrl: "toggle-element.html", link: function(scope){ scope.toggled = false; scope.toggle = function(){ scope.toggled = !scope

Update scope with satellite data

我是研究僧i 提交于 2019-12-13 21:18:41
问题 Suppose that you have an array of objects in your scope and that you want to update it with a directive. How can I do that ? I am not really sure what should be done. The main point is that I want to update the scope with the name and the "satellite data" which is the id in this case but we could imagine that we have more of it. Question : Why would I need an id value anyway if I don't bother showing it in the UI ? Imagine that instead we are talking to a database and that the database is

how to search and highlight in angular js?

本秂侑毒 提交于 2019-12-13 21:14:43
问题 I have a div in which I have some contend in that .I need to search text from that div and highlight the word (using css class).using next it search next word occurrence and previous occurrence. I am able to make in jquery as example in fiddle http://jsfiddle.net/3MVNj/5/ can you please suggest how I will achieve this in angular js ? plunker http://plnkr.co/edit/V805fEjJAUbAZIuafJcW?p=preview <!DOCTYPE html> <html ng-app="app"> <head> <link data-require="bootstrap-css@3.x" data-semver="3.2.0"