0
votes
1answer
15 views

AngularJS - How to get directive-controller in directive with “require”

I have a directive with a require. Now I want to get the required controller instance AND the controller of the directive in the link function. How is that possible? If i set 'require' the fourth ...
0
votes
1answer
28 views

Getting data from a Controller/Service into a Directive?

I'm a relative beginner with AngularJS and am writing an app that will have various reusable components (e.g. the same table may appear 5 times on the screen, with slightly different columns - I can ...
0
votes
2answers
41 views

angularjs directive controller $element

i see angularjs highly suggested not to do any dom manipulation in the controller, only setting the state of the scope, example pulling data from ajax etc, https://docs.angularjs.org/guide/controller ...
0
votes
2answers
54 views

Directive talks to controller but cannot call functions residing in controller

I have a directive which needs to call functions from the Main controller but everytime i try to reference a function inside the directive nothing happens because it's undefined. When I access a value ...
1
vote
1answer
16 views

How to append a directive to another directive which calls a function from controller.

I'm trying to append a directive which occurs when an event is fired via the $watch function in angular. The first directive updater would insert a custom element <confirmation /> into my view. ...
0
votes
1answer
38 views

Initiating directive from controller

I'm having trouble figuring out a way to initiate a directive once the data has been returned. I'm trying to build a report using html tables and ng-repeat. The report object is generated using a ...
0
votes
1answer
37 views

Angular directive - when to prefer using a controller inside a directive?

I've been seing a lot of directive containing a controller in it. What are the pro / cons /differences and use cases compared to put the same code in the link function of the directive ? One ...
1
vote
2answers
35 views

In an AngularJs directive, how do I call its controller's function contained within an directive element's attribute?

I am trying to call a function in a controller, which is part of a custom angular directive, following is the code, Method 1: (Doesn't work: Controller's function doesn't write to the console) HTML: ...
1
vote
2answers
58 views

How to pass async data from directive to controller?

I want to compile a third-party api (uploadcare) to a directive. The api will return the data info after uploaded in async then I want to do something with the return data in my controller but I have ...
0
votes
1answer
94 views

changing model objects inside controllers to manipulate DOM - angular js- Best practices?

I hava a simple question after reading the post below and working for some time now on angular js. the post : no dom manipulation from angular js controllers the concerned point (from the post) : ...
0
votes
1answer
72 views

Passing a callback form directive to controller function in AngularJS

I have a directive and a controller. The directive defines a function in its isolate scope. It also references a function in the controller. That function takes a callback. However, when I call it ...
1
vote
0answers
65 views

Angular directive in ng-repeat doesn't call link

I'm fairly new to Angular and am having some trouble getting a directive to render within an ng-repeat. This is probably a lack of experience on my part so any help is greatly appreciated. Here are ...
0
votes
2answers
101 views

angularJS scope not updated for function attribute inside promise block

controller('SomeController', function($scope, simpleFactory, $routeParams) { init(); function init() { var myDataPromise = simpleFactory.getStuff($routeParams.id); // The ...
1
vote
2answers
137 views

AngularJS & Typescript: How to assign a class/type as a directive's controller?

AngularJS directives specify a controller using: { controller: function ($scope){} } As of yet, I have not found a way where I can create a TypeScript class and assign it to a directive's ...
0
votes
0answers
30 views

detect which directive calling a method in the controller

is there any way to detect which directive calling a function in the controller without passing any arguments from the directive itself. simple example to demonstrate what i need: controller: ...
0
votes
1answer
32 views

Angularjs app logic structure help required

I've recently started with Angular and would really appreciate some help on how to properly structure my code the angular way. This is more of a meta question rather then technical question. I have ...
2
votes
1answer
82 views

How to dynamically load controller to a directive

So I have a directive that Will be acting as a side panel in my app. When a user clicks a button the side panel will open. In said side panel I need the controller and view for this area to be ...
0
votes
0answers
196 views

angular directive for tables: bind transcluded elements with ng-bind-html

I'm trying to write a generic table directive like this: <h-table rows="customers"> <h-column field="Id"> <a ng-click="editCustomer(row.Id)">{{row.Id}}</a> ...
0
votes
1answer
21 views

Change ng-model through directive

I'am trying to change ng-model of input inside directive by clicking on Edit anchor in directives template. Function f() is suppose to access outer controller and bind the editableValue to name or ...
0
votes
2answers
81 views

AngularJS: How to inject service into directive

I’m failing on injecting a service into a directive – it works with my controller though. According to the doc, it should be pretty straight forward. Service: priceGraphServices = ...
2
votes
1answer
49 views

Directives & Controllers: resolve, loading, reloading [closed]

I need a code for the next problem. I know which components ($http, $q, etc.) I have to use. I don't know how to do it in a right way! So, I need an AngularJS directive or controller, It loads some ...
0
votes
1answer
57 views

angularjs directive comunication

I am new to angularjs, and i have been reading a ton of documentation and reading through various articles and tutorials as well as videos to help me figure this stuff out. i am trying to get two ...
1
vote
1answer
107 views

How can I get controller scope reliably in directive?

Let's say I have a directive that simply print out its scope id .directive('myCustomer', function() { return { template: 'directive scope {{$id}}', link: function(scope, el, attrs) { ...
0
votes
1answer
61 views

How do I access the controller I declared for an angularjs directive in the templateUrl?

I would like to use a directive with a controller but I would like to access the same controller in the url template. How can I do this? For example, I would like something along the lines of: ...
0
votes
0answers
39 views

ng-if / manually binding controller causes DOM Node count increase

I'm writing a directive to bind a template with a controller dynamically. During this, I found that the DOM Node count kept increasing, (and the heap size too). I'm wondering what is wrong with the ...
0
votes
1answer
19 views

In angular, how do you provide a controller's argument list from within a directive definition?

I'm trying to follow the best practice of providing an argument list when defining a controller, like this: angular.module("myApp", []) .controller("myCtrl", ["$scope", function ($scope) { // ...
0
votes
4answers
51 views

Angular Directives: Link to Controller without Services

I'm gradually getting the hang of Angular directives and so far, have resorted to creating a service as an intermediary between controllers. I was just wondering, in the context of directives (and ...
2
votes
2answers
110 views

Did I share state correctly outside angular directive? (parent scope / $rootScope issue)

I have two elements on my page which are not nested in some way. With attributes on the first one, I would like to set the content of the second one, like so: <body> <input info="This is ...
0
votes
3answers
96 views

When i require ngModel controller how do I access a property of the model controller

I am using ng-repeat and setting a model with it similar to the following <div ng-repeat="thing in things" ng-model="thing" my-directive> {{thing.name}} </div> then in my ...
0
votes
1answer
193 views

Use ng-if inside other directive with separate scope

Currently I've got the following HTML: <div ng-controller="WaitForViewCtrl"> <div ng-if="show"> ... </div> </div> WaitForViewCtrl controller watches ...
0
votes
1answer
48 views

Directive Inside another directive. Controller can't watch

I have 2 simple directives... the parent directive: .directive('modal', [function () { return { replace: true, scope: { /* attributes */ }, templateUrl: 'modal.tpl.html', transclude: ...
1
vote
2answers
251 views

Define a dynamic controller in an AngularJS directive?

I have a directive that has a dynamic template, now I want the directive to have the ability to use different controllers. Is it possible to dynamically assign a controller to a directive? If ...
0
votes
1answer
49 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
324 views

Scope Variable Not Being Set Outside of Directive

I am attempting to create an AngularJS directive that sends a file name, from an <input type="file"> element, to a file upload factory. The work is based off the following blog post: ...
3
votes
1answer
413 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
1answer
3k views

prevent default on submit :- Angularjs

I want to prevent-default action of http-post to '/signUp' if e-mail is null upon filling form. Controller Code:- $scope.signUp = function() { if($scope.email = null); preventdefault; } ...
0
votes
1answer
24 views

How to bind a transcluded template to a different controller?

I'm trying to pass a template through a directive to a dynamic controller (known at runtime from the directive perspective). Something like this: <my-dir ctrl="PersonCtrl"> ...
1
vote
2answers
2k views

access parent directive's controller by require: '?^…' recursively

I'm trying to reach the controller of a parent "box" directive recursively: <body ng-app="main"> <!-- no nesting: parent is the just body --> <box></box> <script ...
1
vote
1answer
41 views

Communication from Diretives to Controller in Angularjs

I am new to angularjs. I have following code , Now i want to access object of map in controller. here i am not able to know, how to pass it to controller? My Custom Directive : ...
2
votes
1answer
970 views

Pass Arguments from directive to controller function

I've seen lots of these questions but haven't found a solution that works. here is a fiddle that doesn't work but should. http://jsfiddle.net/cdparmeter/j2K7N/2/ Controller: $scope.foo = function ...
3
votes
0answers
46 views

The difference between a compile/link function and a controller function in AngularJS? [duplicate]

I'm trying to write my own AngularJS directives. I think I understand the difference between the compile and link functions. This video clears it up nicely. But I'm not sure now that I understand the ...
2
votes
2answers
77 views

AngularJS Directives and the Model

I'm not sure this question's been asked, but is it good practice (not ok-to-do) to mess with the data model from an AngularJS directive? For instance, if in my controller I have some object, like: ...
0
votes
1answer
190 views

Angular access controller scope from nested directive

this fiddle represents what i am trying to do: http://jsfiddle.net/d1001001/dwqw6/. The grid directive needs to grab some data from controller, but since it's nested in the modal directive, which has ...
0
votes
1answer
775 views

AngularJS - Pass variable from a controller & update from directive

I've set one Plnkr. I want to dynamically add input fields in a directive. The input fields are to be built by a collection from a controller. And change the values of the inputs. But the main problem ...
0
votes
2answers
778 views

How to connect my controller in my directive for inserting data and adding bootstrap select in angular.js?

I'm trying to add data on my select menu using a controller and used ng-options while i have a class defined in my directive to insert the bootstrap-select plugin to the element. The problem is that ...
0
votes
0answers
126 views

How to have page controller execute directive functionality AngularJS

Lets say I have a directive that has an isolate scope and that scope have a method on it. Now is there an Angular way to allow the page controller to be able to call functionality declared in a ...
2
votes
1answer
2k views

Jquery animation in a AngularJS controller or directive?

I have an app in AngularJS and in one of my view I want to implement some JQuery animation..nothing too fancy..just hide/slide of a divs ..those divs are created from ng-reapet loop and I need access ...
0
votes
0answers
257 views

AngularJS - Create a directive to fire an event (function) when the current element is appended to the DOM

I am trying to find a way to detect when an element is finally appended to DOM? Is there any directive that I can create and attach to that element so it will detect the moment of appending? By ...
4
votes
1answer
2k views

AngularJS - How do I avoid using $timeout to wait for an element to be created?

Here is the idea: So I am trying to use an external library function to create some manipulation in the DOM in one of my controllers that my ng-repeat is connected to. Newest jsFiddle working but ...
0
votes
1answer
229 views

Angular using another directive's controller?

If I have two directives, and need to have one of them use the controller of the other one, what is the best way to accomplish something like that in angular? I'm trying to use the require: ...