angularjs-directive

AngularJS communication between directives

好久不见. 提交于 2019-12-17 02:38:11
问题 I'am new to Angular.js, I need for my application some communication between directives, I read some documentation about link and require, but can't understand exactly how it works. For a simple example I have : live fiddle : http://jsfiddle.net/yw235n98/5/ 2 directives : firstDir, secondDir :: with some data firstDir have a click function that will change the data value when firsDir click function is triggered I want to change data in secondDir too. HTML : <body ng-app="myApp"> First

AngularJS communication between directives

大憨熊 提交于 2019-12-17 02:38:05
问题 I'am new to Angular.js, I need for my application some communication between directives, I read some documentation about link and require, but can't understand exactly how it works. For a simple example I have : live fiddle : http://jsfiddle.net/yw235n98/5/ 2 directives : firstDir, secondDir :: with some data firstDir have a click function that will change the data value when firsDir click function is triggered I want to change data in secondDir too. HTML : <body ng-app="myApp"> First

How to set bootstrap navbar active class with Angular JS?

十年热恋 提交于 2019-12-17 00:20:25
问题 If I have a navbar in bootstrap with the items Home | About | Contact How do I set the active class for each menu item when they are active? That is, how can I set class="active" when the angular route is at #/ for home #/about for the about page #/contact for the contact page 回答1: A very elegant way is to use ng-controller to run a single controller outside of the ng-view: <div class="collapse navbar-collapse" ng-controller="HeaderController"> <ul class="nav navbar-nav"> <li ng-class="{

AngularJS 1.5+ Components do not support Watchers, what is the work around?

笑着哭i 提交于 2019-12-16 20:16:55
问题 I've been upgrading my custom directives to the new component architecture. I've read that components do not support watchers. Is this correct? If so how do you detect changes on an object? For a basic example I have custom component myBox which has a child component game with a binding on the game . If there is a change game within the game component how do I show an alert message within the myBox? I understand there is rxJS method is it possible to do this purely in angular? My JSFiddle

AngularJS 1.5+ Components do not support Watchers, what is the work around?

牧云@^-^@ 提交于 2019-12-16 20:16:32
问题 I've been upgrading my custom directives to the new component architecture. I've read that components do not support watchers. Is this correct? If so how do you detect changes on an object? For a basic example I have custom component myBox which has a child component game with a binding on the game . If there is a change game within the game component how do I show an alert message within the myBox? I understand there is rxJS method is it possible to do this purely in angular? My JSFiddle

AngularJS 1.5+ Components do not support Watchers, what is the work around?

天大地大妈咪最大 提交于 2019-12-16 20:16:03
问题 I've been upgrading my custom directives to the new component architecture. I've read that components do not support watchers. Is this correct? If so how do you detect changes on an object? For a basic example I have custom component myBox which has a child component game with a binding on the game . If there is a change game within the game component how do I show an alert message within the myBox? I understand there is rxJS method is it possible to do this purely in angular? My JSFiddle

How to set an iframe src attribute from a variable in AngularJS

怎甘沉沦 提交于 2019-12-16 20:13:29
问题 I'm trying to set the src attribute of an iframe from a variable and I can't get it to work... The markup: <div class="col-xs-12" ng-controller="AppCtrl"> <ul class=""> <li ng-repeat="project in projects"> <a ng-click="setProject(project.id)" href="">{{project.url}}</a> </li> </ul> <iframe ng-src="{{trustSrc(currentProject.url)}}"> Something wrong... </iframe> </div> controllers/app.js: function AppCtrl ($scope) { $scope.projects = { 1 : { "id" : 1, "name" : "Mela Sarkar", "url" : "http:/

angular ng-bind-html and directive within it

天涯浪子 提交于 2019-12-16 19:58:29
问题 Plunker Link I have a element which I would like to bind html to it. <div ng-bind-html="details" upper></div> That works. Now, along with it I also have a directive which is bound to the bound html: $scope.details = 'Success! <a href="#/details/12" upper>details</a>' But the directive upper with the div and anchor do not evaluate. How do I make it work? 回答1: I was also facing this problem and after hours searching the internet I read @Chandermani's comment, which proved to be the solution.

dynamic grid as custom directive

谁说胖子不能爱 提交于 2019-12-14 04:09:07
问题 I am relatively new to Angular and got stuck on a custom directive. I am trying to create a dynamic grid as a custom directive. I already got that part working as in this example: working grid as custom directive There are certain scenarios where I need to set attributes on some of the elements of the grid. This part has got me stumped. I am planning on including the attributes as an array inside the object and then just putting it in the html tag of the associated entry. This part is

is it necessary to include a destroy method in my directive

☆樱花仙子☆ 提交于 2019-12-14 04:09:01
问题 I've written a pretty simple directive that adds/removes a css class on an element when the element is clicked. app.directive('dropdown', function() { var open = false, element, callback = function(){ open = !open; if (open) { element.addClass('open'); } else { element.removeClass('open'); } }; return { scope: {}, link: function(scope, elem){ element = elem; elem.bind('click', callback); scope.$on('$destroy', function(){ elem.unbind('click', callback); elem.remove(); }); } }; }); I think that