angularjs-directive

Why does the directive ng-href need {{}} while other directives don't?

不打扰是莪最后的温柔 提交于 2019-12-03 04:45:19
问题 I am just wondering why I need to add double curly braces for ng-href while some of the other directives don't need them? <a ng-href="{{myScopeVar}}" ng-if="myScopeVar">link</a> Notice that ng-href needs braces while ng-if doesn't. 回答1: I am not quite sure about your question. But i think your are wondering why there are different syntax styles in angular directives. First off all, please have a look at this post: Difference between double and single curly brace in angular JS? The answer

How to asynchronously load a google map in AngularJS?

南笙酒味 提交于 2019-12-03 04:44:25
Now that I have found a way to initialize Google Maps with the help of Andy Joslin in this SO initialize-google-map-in-angularjs , I am looking for a way to asynchronous load a Google Map Object. I found an example of how to do this in the phonecat project. Notice how the JS files are loaded in this example: index-async.html In my Jade Scripts partial that is loaded into my program I tried: script(src='js/lib/angular/angular.js') script(src='js/lib/script/script.min.js') script $script([ 'js/lib/angular/angular-resource.min.js', 'js/lib/jquery/jquery-1.7.2.min.js', 'http://maps.googleapis.com

Communicating with sibling directives

泄露秘密 提交于 2019-12-03 04:41:37
问题 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

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

主宰稳场 提交于 2019-12-03 04:40:43
问题 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 ==

Uploading a file with AngularJS and bluimp on success callback of another form

∥☆過路亽.° 提交于 2019-12-03 04:38:56
问题 I have followed the following tutorial in order to integrate the notorious bluimp jQuery file uploader in my AngularJS project. After some research I found that in the options array, witihn the jquery.fileuploader.js file, there is an option called autoUpload, which when set to true upload the file automatically. I tried to disable it(false, undefined), but quickly I learned out that this causes the upload not to function at all, not even on the form submit. I need to trigger the upload

AngularJS: Access formController of a form placed inside transcluded directive from parent controller

試著忘記壹切 提交于 2019-12-03 04:19:16
问题 I've created a simple "modal dialog" directive, which uses transclude. I would like to place a form () inside the "modal dialog" directive. I would expect that formController of a form placed inside the directive, is going to be accessible in parent controller's scope, however it isn't. Take a look at the following fiddle, please: http://jsfiddle.net/milmly/f2WMT/1/ Complete code: <!DOCTYPE html> <html> <head> <title>AngJS test</title> <link rel="stylesheet" type="text/css" href="//cdn

AngularJS directives attributes access from the controller

扶醉桌前 提交于 2019-12-03 04:08:35
问题 I am trying to access the attributes of a directive in the controller function. However, by the time I access it, it is undefined. I noticed that if I do a simple timer it works. Is there a way to execute code only after the directive and it's scopes are ready and set to be used? I made a fiddle with it. Make sure your console is open. http://jsfiddle.net/paulocoelho/uKA2L/1/ Here is the code I am using in the fiddle: <div ng-app="testApp" > <testcomponent text="hello!"></testcomponent> </div

jQuery find() method not working in AngularJS directive

孤街醉人 提交于 2019-12-03 04:04:36
问题 I am having trouble with angularjs directives finding child DOM elements with the injected angular element. For example I have a directive like so: myApp.directive('test', function () { return { restrict: "A", link: function (scope, elm, attr) { var look = elm.find('#findme'); elm.addClass("addedClass"); console.log(look); } }; }); and HTML such as : <div ng-app="myApp"> <div test>TEST Div <div id="findme"></div> </div> </div> I have access to the element which is proffed by adding a class to

How to replace the element with ng-transclude

好久不见. 提交于 2019-12-03 03:37:34
问题 Is it possible to replace the element with ng-transclude on it rather than the entire template element? HTML: <div my-transcluded-directive> <div>{{someData}}</div> </div> Directive: return { restrict:'A', templateUrl:'templates/my-transcluded-directive.html', transclude:true, link:function(scope,element,attrs) { } }; my-transcluded-directive.html: <div> <div ng-transclude></div> <div>I will not be touched.</div> </div> What I am looking for is a way to have <div>{{someData}}</div> replace

Angular Search for value in JSON and display corresponding data

隐身守侯 提交于 2019-12-03 03:23:12
问题 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,