angularjs-directive

Angular Share Variable betwen $http.get and controller [duplicate]

て烟熏妆下的殇ゞ 提交于 2019-12-11 13:54:39
问题 This question already has answers here : How do I return the response from an asynchronous call? (36 answers) Closed 4 years ago . I can't pass the content of one variable inside $http.get() to outside of this method... it's always undefined . I tested with $rootScope , but it didn't work. controller('myControl', function ($scope, $http) { var content; $http.get('../Json/data.json').success(function (data, content) { content = data; }).error(function (data, status, headers, config) { $scope

d3js angular directive for area chart using d3.mouse event for tooltip

江枫思渺然 提交于 2019-12-11 13:53:45
问题 I have this http://plnkr.co/edit/fZXbWTGH4qTP4E9LkKyw?p=preview where if you hover over the area chart it should have shown the tooltip as the follow up from here roi value in tooltip d3js area chart. svg.append("path") .data([data]) .attr("class", "area") .attr("d", area) .on("mouseover", function () { tooltip.style("display", null); }) .on("mouseout", function () { tooltip.style("display", "none"); }) .on("mousemove", function (d) { var xPosition = d3.mouse(svg)[0] - 15; var yPosition = d3

why alert is not display in angularjs

天涯浪子 提交于 2019-12-11 13:51:53
问题 I am trying to use require js in angular js project .I am able to show view but issue is that I am not able to get alert on "Login" button click .Actually I show One alert on button click . Here is my code http://plnkr.co/edit/jv79297BZLiJpY66rKAc?p=preview function ctrl($scope, $state) { $scope.login = function () { alert("Login is clicked") }; } I think I got error on console that why I am not able to display alert ? http://errors.angularjs.org/1.2.12/ng/areq?p0=LoginCtrl&p1=not%20a

How to use index of each item when item is written in directive?

泪湿孤枕 提交于 2019-12-11 13:44:39
问题 I just want to point out that this is my first attempt to create simple app in AngularJS .I have a table , and in each row I'm displaying task which contains Index,Name,Activity,Time properties and also edit and delete buttons.Everything is working perfect. <table class="table table-striped " style="width: 100%"> <tr ng-repeat="task in tasks" > <td>{{$index}}</td> <td>{{task.name}}</td> <td>{{task.activity}}</td> <td>{{task.time}}</td> <td ><button type="button" ng-click="editRow($index)"

How to assign a (dynamic) variable in HTML using angularJS

狂风中的少年 提交于 2019-12-11 13:35:23
问题 I have a complex directive I use though out my application on many HTML pages. It has become complicated and contains nested structures so I copy and paste it everywhere: <card ng-repeat="card in deck" scalex="card.scalex" scaley="card.scaley" ... <img ng-repeat="wait in [] | range:card.f" src="symbol.png" style="position:absolute; left:{{(13*$index + 3 )}}px; z-index: 1;bottom:0px"></img> ... <icon ng-repeat="icon in card.icons" x="icon.x" y="icon.y" ... /> </card> However, not always is

why wont ng-keypress change ng-model values

若如初见. 提交于 2019-12-11 13:33:13
问题 Please check out my jsFiddle Mousing over divs .box.red || .box.blue will allow it to be focused and values to change of ng-model to be changed scope.box = {'blue': 0, 'red': 0}; This change happens during a ng-keyup ng-keydown event. keyup will change +1 to the value; keydown will change value by -1. html <div ng-controller="MyCtrl"> <div class="bounding"> <h2><i>mouseover</i> box then <i>keypress</i> <span>up</span> or <span>down</span> arrows indivually edit values of input model </h2>

Wrapping angular typeAhead in separate directive

萝らか妹 提交于 2019-12-11 13:29:28
问题 My goal was to wrap angular-ui typeAhead directive into easily re-usable component, that could be used like this: <input my-person-lookup="myModel.personId" ></input> I've achieve this by writing my custom directive, and specifying static template for typeahead. Here is Plunker Now, I would like to build this template dynamically, and then compile it: var html = '<input type="text" ng-model="directiveModel.selectedPerson" typeahead=" p as p.name for p in people" typeahead-min-length="1"

Angularjs directive to make form dirty without ng-model

我与影子孤独终老i 提交于 2019-12-11 13:28:48
问题 I am using Angular 1.5.1. I have a checkbox on my form. I do not care about the truth/false indicator of the checkbox being checked/unchecked and so I do not want ng-model on it. What I care for is: when checkbox is unchecked, I delete a specific array from my model when checkbox is checked, I add an empty array back to my model So I have created a directive that provides me with this functionality, very simple: .directive('cbOnChecked', function() { return { restrict: 'A', link: function

Show the input[type=file] filename at directive template

微笑、不失礼 提交于 2019-12-11 13:11:39
问题 I'm trying to implement something like the bootstrap-file-uploader in pure angular. This bootstrap extension replaces the default file-upload widget with a consistent alternative (see this jsfiddle). I'm unable to show the selected filename in another element from the same directive. Tried the following already: scope.fileName = files[0].name ngModel scope.$apply. The event is fired and value is changed, but the change is not reflected in the interface. angular.module('app', []) .directive(

AngularJS directives to hide zero when <input> is initially loaded to the DOM

泄露秘密 提交于 2019-12-11 13:10:29
问题 I am trying to implement an angular directive that will hide zero of field as soon as the is on DOM. basically this Hide Value in input when it's zero in angular Js my code look something like this : <input hide-zero-onload ng-model="test"></input> .directive('hideZeroOnload', function() { return { link: function(scope, element) { element.on('input load', function() { console.log('loaded'); if (this.value === '0') { this.value = '-'; } }); } }; }); However,the console log is never printed. I