angularjs-directive

How to create network graph or hierarchical tree using visjs in angularjs?

吃可爱长大的小学妹 提交于 2019-12-02 17:16:20
问题 I need some help in creating a network graph using visjs in angularjs. I am working on this plunker to achieve something like this I followed the steps mentioned in AngularJS - visjs but was unable to make it work so I created a plunker (given above) to get help from community. Controller code. var app = angular.module('app', ['ngVis']); app.controller('MainCtrl', ['$scope', 'VisDataSet', function($scope, VisDataSet) { $scope.data = VisDataSet({ "1": { "id": 1, "content": "<i class=\"fi-flag\

Communicating with sibling directives

眉间皱痕 提交于 2019-12-02 17:12:07
Goal: Create behaviors using directives with communication between 2 sibling elements (each their own directive). A behavior to use in example: The article content is hidden by default. When the title is clicked, I want the related article content to display. The catch: The related article elements need to associate to each other without being nested in a single parent element or directive. <div article="article1">this is my header</div> <div id="article1" article-content>this is content for the header above</div> <div article="article2">this is my header</div> <div id="article2" article

How to inject a service in a directive unit test in AngularJS

允我心安 提交于 2019-12-02 17:09:34
I need to test a directive that does some calls to some injected services. The following piece of code is an example directive, that listens for events, and redirects the browser if enter is pressed inside a specified element. Edit: I get the feeling I may be wading in E2E testing land? angular.module('fooApp') .directive('gotoOnEnter', ['$location', function ($location) { var _linkFn = function link(scope, element, attrs) { element.off('keypress').on('keypress', function(e) { if(e.keyCode === 13) { $location.path(scope.redirectUrl); } }); } return { restrict: 'A', link: _linkFn }; }]); The

Angular Search for value in JSON and display corresponding data

我是研究僧i 提交于 2019-12-02 16:52:36
What i am trying to do is simple. A user enters a value, on button click, my JS calls a service to retreive my JSON data and perform a search on the value entered against the JSON and if a match is found, display the 'Owner'. HTML: <div ng-app="myApp"> <div ng-controller="MainCtrl"> <input type="text" ng-model="enteredValue"> </br> <button type="button" ng-Click="findValue(enteredValue)">Search</button> </div> </div> JS: angular.module('myApp', []).controller('MainCtrl', function ($scope, $http, getDataService) { $scope.findValue = function(enteredValue) { alert("Searching for = " +

How to change class depending on filter result in AngularJS?

和自甴很熟 提交于 2019-12-02 16:13:31
问题 I cannot work out how to change the style of a class depending on the status/result of the filter. My code: <div data-ng-if="search.length >= 3" > <div data-ng-class="{list:true}" style="margin-top: 30px;"> <a class="item item_recipe" data-ng-repeat="item in items | nonBlankFilter:search | filter:search" data-ng-click="$emit('search.click',item.PK);"> <img class="thumbnail" src="images/thumbnails/{{item.THUMB}}"> <div class="title">{{item.TITLE}}</div> </a> </div> What is happening now, is

Callback function inside directive attr defined in different attr

拥有回忆 提交于 2019-12-02 16:11:57
So I have this directive called say, mySave , it's pretty much just this app.directive('mySave', function($http) { return function(scope, element, attrs) { element.bind("click", function() { $http.post('/save', scope.data).success(returnedData) { // callback defined on my utils service here // user defined callback here, from my-save-callback perhaps? } }); } }); the element itself looks like this <button my-save my-save-callback="callbackFunctionInController()">save</button> callbackFunctionInController is for now just $scope.callbackFunctionInController = function() { alert("callback"); }

Angular directive add template on textbox (enter of Spacebar)

妖精的绣舞 提交于 2019-12-02 16:09:22
问题 I am using angular js,My target is to show a html table on (enter of spacebar) in textbox and add the element of the table in that textbox,for that i have written a directive,but i am not sure whether i have done it in right path..Ohk i will show it in detail to be more clear Here is my html textbox <input type="text" helps ng-model="firstText" code="1"> <div class="col-xs-4 pull-right" helps donotapply=true></div> //Do i need this?? Here helps is my directive which binds my html to the div

angular.module requires doesn't work

孤者浪人 提交于 2019-12-02 15:56:17
问题 I'm new with angularjs and I'm having some problems with the controllers. When I try to put something in the angular.module I only can specify the name, if I put something in the requires part all the page stop working. For example: If I put angular.module('name',[]) it doesn't work but if I put angular.module('name') it works properly. Somebody knows why is it? 回答1: This statement angular.module('name',[]) creates a module, whereas this statement loads the module angular.module('name') The

How to append directives based on conditions

守給你的承諾、 提交于 2019-12-02 15:39:16
问题 I have 2 different directives. The first one is returns an iframe with a live video, and the second returns an iframe with a recent video. The condition is: if live content is present, append live directive, else append recent video directive. Ive tried with normal html instead of the directives and it works, but when i put the directive element, unfortunately doesnt work. WORKING controller.js function isLiveOn() { var liveIframe = '<h2>LIVE</h2>'; var videoIframe = '<h2>VIDEO</h2>'; if (vm

How to replace an element in AngularJS directive linking function?

一个人想着一个人 提交于 2019-12-02 15:29:31
I'm creating a <row> AngularJS directive that needs to replace itself (the <row> tag must not be present in the DOM after execution) with a dynamic template that can contain any HTML code. The problem in using replace: true is that it does not work with table's <tr> tags and that the template is dynamically chosen. So I'm trying to find a way to replace the element in the linking function, with no success. Using jQuery's .replaceWith() breaks ngRepeat for unknown reason. Any hints? Here is the fiddle Your fiddle seems pretty basic but you should be able to just use outerHTML element[0]