Tagged Questions
1
vote
1answer
26 views
Call controller function from angular directive
How can I call angular function inside directive which is defined in controller?
var app = angular.module('myApp', ['ngResource']);
app.directive('hello', function () {
return {
scope: {
...
0
votes
2answers
23 views
Angular directive not showing
I've got a tiny problem with an angular directive that's now working and I don't know why. I think it's a fairly simple issue that I'm overlooking, maybe you can help me out.
Directive is defined ...
0
votes
1answer
20 views
Angular Directive - Nested Object in Attr
There is great solution provided for this question, that shows how to use a directive to display <tr>'s for nested objects. However, I need to take it a step further and pass a nested object ...
0
votes
1answer
19 views
Destroying child directive scope
In my application i've created two directives, one parentDirective and childDirective.The parent directive dynamically creates child directives depending on some criteria defined in parent on button ...
0
votes
1answer
32 views
AngularJS - hide a div when clicking in an inner element using a directive
I'm trying to hide a box when clicking on a link inside this box.
I wan't to use a directive to be able to add more code when once the box is hiden and to keep it generic so I can use that with other ...
0
votes
2answers
21 views
AngularJs ng-if for displaying or skipping on element
I am using AngularJS.
I have the following template:
<div>
... html content ....
</div>
I want to wrap the html content with an anchor only if the url model is not empty. For ...
0
votes
1answer
47 views
How to get the form data when the form is in a directive in Angular?
I have this this template:
<div class="modal" id="popupModal" tabindex="-1" role="dialog" aria-labelledby="createBuildingLabel" aria-hidden="true">
<div class="modal-dialog">
...
0
votes
0answers
24 views
How to expand a tree in javascript which is generated using a recursive directive in Angular?
I build a tree using a recursive directive:
app.directive('recursiveListItem', ['$http', 'RecursionHelper', function ($http, RecursionHelper) {
return {
restrict: 'E',
scope: {
...
0
votes
1answer
14 views
AngularJs accessing attribute difference, via linking and scope
Can anyone explain whats the difference between accessing directive attribute from the scope as in :
scope: { someVar: '=' }
vs
link: function (scope, elem, attr, ctrl) {
attr.someVar
}
It ...
0
votes
0answers
16 views
In template of the directive i had added the click event which was handling in the link .But the issue is that the function is calling two times
this is my directive .IN this i had added the ng-click for the li with the display of the item name but the function is calling for two times .Any one can you please explain it was happening .below ...
1
vote
4answers
70 views
AngularJS directive gets not updated if scope variable changes
I've tried to write a small directive, to wrap its contents with another template file.
This code:
<layout name="Default">My cool content</layout>
Should have this output:
<div ...
0
votes
1answer
28 views
How get Data from AngularJS using a scope with different kinds of Propierties?
I have assigned to an scope object an object (class) but this class has two attributes: two arrays and two strings, how can i get the values from this $scope??
Ex: Object to Assign:
var Address ...
0
votes
1answer
43 views
Changing colour of angularjs slider with pointer
Hi I'm building a slider in angularjs that changes color depending on where you move the pointer.
1.) if the pointer is on the rightside, the bar will be red
2.) if the pointer is on the leftside, ...
0
votes
1answer
35 views
concatenate the array name with a string
I am working on an AngularJs app. I have an array of HTML select tags where I am concatenating the ng-model name and the options list name with a variable. He re I have two list or arrays. the first ...
0
votes
1answer
9 views
Why isolate scope “@” and $apply don't work as expected
I've been studying AngularJS and in particular saw the video:
http://www.thinkster.io/pick/IgQdYAAt9V/angularjs-directives-talking-to-controllers
This video presents an example of a directive ...
0
votes
1answer
28 views
Newbie Angular Q - Modifying service output
I've been working on my first angular app all day and have a basic question.
The goal is to create a text field with two strings describing the current url route and action like the following:
You ...
1
vote
1answer
31 views
How to reach a function from a directive that is defined in the inline controller
If I have a directive, that has its own controller defined in its body:
directives.directive("formWrapper", ['User','$location', function(User, $location) {
return {
...
template: ...
0
votes
0answers
37 views
Custom AngularJS attribute inside the directive with HTML page template
I want to create two directives: one of them should be an simple tag and another one should be an attribute for this tag.
Another words I want to make something like this:
<outer ...
1
vote
0answers
42 views
patch request using angularjs
I am working on an API using djang-tastypie as backend and AngularJs for front end. I am sending request fro CRUD using angularjs $http. GET, POST, PUT everything is fine but when I am trying to send ...
0
votes
1answer
23 views
AngularJS - Trouble with directive changing value in controller
I'm getting large images from an API in my main controller.
I have a directive that successfully lets me know when each image is loaded:
app.directive('imageonload', function() {
return {
...
0
votes
0answers
23 views
angularjs directive accessing original nested elements
Pretty basic scenario, just not sure how to approach it
I have an angular app, I have an element restricted directive that uses a templateUrl to bring in a partial.
The partial works fine and looks ...
0
votes
0answers
18 views
Linking and controller function of directive which is represented as an attribute of another directive don't work
Have the following problem. I want to make two directives. One of them will be an attribute for another.
Something like this.
<html>
<title>Directives</title>
<head lang="en">
...
3
votes
1answer
120 views
angular.js directive templateUrl fails to bind scope
I'm creating a directive that will display and show content by listening to the $routeChangeError event on $rootScope.
I got it all to work by inlining the template like this:
app.directive("alert", ...
0
votes
1answer
23 views
Select Last HTML Select element from multiple select elements using AngularJs
Hello guys I am working on an application where I am using django-tastypie as backend and AngularJs for front end.I am totally new to AngularJs. In my template there may be multiple HTML Select tags ...
0
votes
2answers
33 views
Calculate mathematical expression within string in angularJS
How do I evaluate the mathematical expression within a string and assign it to a numerical value in angularJS?
Eg: var value = 10;
var someValue = "Math.min(value * 0.22, 106800)". I need someValue ...
0
votes
1answer
30 views
Angularjs creating questionaire that allows ranking choices
I'm creating a questionaire for users that allow them to choose and rank personality attributes that best match them. There are three choices in each row and everytime they click on a choice it ...
1
vote
1answer
75 views
Recursion using Angularjs and Append Elemnts to an HTML Template
I am quite new to Angularjs . I am working on an app which use Angularjs for front end and django-tastypie for back end. What I am doing is i have a topics list where topics are nested in each others ...
0
votes
1answer
24 views
Applying math rules (like rnd, max etc) to value entered by user using AngularJS directive
I have sum calculation rules defined as below, where 2013 represents the year and 5 and 6 are some codes sent over to the program:
app.run(function($rootScope) {
$rootScope.MATHRULES = {
...
0
votes
2answers
20 views
Why does changes to the outer scope from within a directive require scope.$apply() even if I am setting scope option to false?
Lately I've noticed that changed to some angular - provider objects, or to my own - outer scope(out side of the directive, in the controllers) required wrapping the code in scope.apply().
can anyone ...
2
votes
1answer
59 views
Isolated scope for directives
I'm having some troubles understanding isolated scopes in Angular directives. I've read the official documentation, watched a lot of videos about the subject, so now I'm know what's the purpose of ...
1
vote
1answer
41 views
AngularJS Directive - Receiving a broadcast from $rootscope
I have the following code,
HTML
<div ng-app="test">
<div ng-controller="containerCtrl">
<component data-module="components"></component>
</div>
...
3
votes
2answers
56 views
Can an angular directive pass arguments to functions in expressions specified in the directive's attributes?
I have a form directive that uses a specified callback attribute with an isolate scope:
scope: { callback: '&' }
It sits inside an ng-repeat so the expression I pass in includes the id of the ...
0
votes
0answers
35 views
How to get the rendered html by AngularJS?
how to get the html rendered inside a div, after it is rendered and put it inside the scope of controller ?
I am new to angular and though i know the basics of directives i cant seem to get the ...
0
votes
1answer
83 views
Angularjs Directive - Isolated scope value is undefined
I am a newbie in angularjs. I am little confused about isolated scope in directives. I have the following code,
HTML
<!doctype html>
<html ng-app="myApp">
<body ...
0
votes
0answers
8 views
$httpBackend prevents normal angular routing; how do I configure $httpBackend to allow normal routing behavior?
I need to load up $httpBackend in order to mock out $http server calls (which return JSON). I've defined my own mocks, but when I load up my angular app with $httpBackend and my own mocks, I get an ...
0
votes
1answer
28 views
Angularjs directive clicking elements
Hi I was wondering when I have a list of elements from a ng-repeat, how I can allow the user to click one of the list and make it highlight via .css(). Then if the user clicks another element, the ...
1
vote
2answers
79 views
Angularjs isolates scope directive with ng-repeat
I'm trying to use directive on ng-repeat items each with an isolate scope but it isn't working. I'm looping through each item and coloring it red with the inboxuser-select directive. However, when I ...
0
votes
1answer
22 views
Custom directive`s scope doesn't pass to child directive
Sorry if I duplicate existing post, but I search SO on the subject and couldn't find description for my case.
I got a custom directive (carousel) that contain inner directives (slides)
Carousel ...
0
votes
0answers
33 views
Angular: Updating directive during request
I'm trying to make a loading bar, almost similar to the one on Google +.
When an action is running, I would like my progress bar to update itself, but it only updates at the start of the request and ...
0
votes
3answers
60 views
How to bind directive model to async service data
I'm trying to do simple thing - bind directive's model to service's data. And all right before service's data loads async (by $timeout or $http request), it simply does not update directive's model.
...
0
votes
1answer
48 views
Directive: I bound isolate scope (“=”) to template ngModel, but input won't update on controller
What I'm trying to do is put the isolate scope 'pointers' directly onto the ngModel within the template. What I expected was for the scope variables to update automatically on the parent controller. ...
0
votes
2answers
123 views
AngularJS Directive using Compile cannot access child elements
My intent was to create a directive that could rearrange (not reorder) its child elements into a Bootstrap CSS Grid, but I am having a lot of difficulty getting access to the child elements.
I've ...
1
vote
1answer
42 views
angularJS: Why does binding to scope inside a directive result in lost content of ng-repeat?
I have this fairly simple HTML structure:
<div ng-controller="MyCtrl">
<div dir1="xy"><div>dir1static</div><div ng-repeat="item in ...
0
votes
1answer
37 views
Angularjs query does not work
Hello friends my english is poor. i'm sorry
How to use it
ng-click="bak = {{maclar.macid}}"
<div><span ng-class="{class:bak == true}" ng-click="bak = {{maclar.macid}}" ...
0
votes
1answer
53 views
Outer AngularJS directive doesn't build inner directive correctly
Using AngularJS 1.0.8, I'm trying to create some reusable directives to create a situation where a web developer can code a single "top-level" directive with a number of attributes, and this ...
0
votes
1answer
36 views
Accessing scope within directive
I have a controller which is charge of getting event json data and if there is data, update the dom with data, else update dom with error message:
//Controller.js
myApp.controller('EventsCtrl', ...
5
votes
1answer
79 views
AngularJS: How to correctly work with Directives, Scopes and Bindings to avoid memory leaks?
I'm trying to find a solution for an AngularJS app memory leak. Because I'm new to the AngularJS world I don't really know where to start and where to correct and optimize my code.
I'm trying to give ...
0
votes
1answer
85 views
Angular.js compiled directive template to string in controller - better way?
I'm using the Angular Leaflet Directive and want to dynamically populate the pop up content.
To populate the content, you can assign an html string to a property called "messages".
Example shown ...
0
votes
0answers
67 views
Nested directives - cannot pass args to controller method from child directive in Angularjs
I'm having some trouble with nested directives in angularjs. I want to call a controller method from a directive within another directive and am trying to pass arguments to it, however they are ...
0
votes
2answers
72 views
How to apply AngularJS Directive to an element after a nested ng-repeat is finished
The html looks like:
<div ng-controller="MainCtrl">
<outer>
<inner ng-repeat="d in data">
<div>{{d}}</div>
</inner>
</outer>
...