Tagged Questions
0
votes
2answers
7 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
50 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 ...
-1
votes
2answers
33 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
46 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
33 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: ...
0
votes
1answer
66 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
20 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 ...
1
vote
1answer
128 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:
...
2
votes
0answers
141 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
437 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
20 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">
...
0
votes
2answers
329 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
32 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 :
...
1
vote
1answer
246 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
43 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
59 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
125 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
394 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
322 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
69 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 ...
1
vote
1answer
1k 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
239 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 ...
2
votes
1answer
985 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
186 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: ...
1
vote
1answer
89 views
AngularJS: How to set controller's property from a directive when using the “Controller As” syntax?
LIVE DEMO
Consider the following example that uses the Controller As syntax:
<body ng-app="myApp" ng-controller="MyCtrl as my">
<div>
{{ my.message }}
</div>
<button ...
0
votes
0answers
205 views
angular ui-select2: fire highlight events programmatically (without using JQuery)
is there a way to call highlight events of select2 in a programmatic way?
something like "ng-highlight"... that will enable writing the callback function of the item-hover in the controller.
...
0
votes
1answer
43 views
Angularjs two separate ui elements communicating
I have a use case to toggle the view of a form using a button. The button is not nested in the same structure of the form, and is out side the scope of the forms controller.
What is the best way to ...
6
votes
1answer
3k views
Sharing data between AngularJS controllers? [duplicate]
How do I store the items I've selected in a checkbox with other controllers?
My attempt (see the plnkr for views):
script.js (controllers)
var myApp = angular.module('myApp', []);
...
3
votes
3answers
6k views
Simple Angular $routeProvider resolve test. What is wrong with this code?
I have created a simple Angular JS $routeProvider resolve test application. It gives the following error:
Error: Unknown provider: dataProvider <- data
I would appreciate it if someone could ...
0
votes
1answer
1k views
Angular JS delay controller and directive initialization until data is returned from server
My AngularJS app requires some metadata from the server before it can initialize the controller and a handful of directives. I have a service to return the data but have been unable to get the ...
1
vote
2answers
259 views
Angularjs: models binding
I have directive which dynamically creates input tags. I need to get values of created inputs on change event. Instead of it the name attribute on $scope argument in the controller is undefined. How ...
2
votes
3answers
2k views
Angular communication between controllers and directives
I have this piece of code which allows a user to leave comments on a list of items.
I created a directive and listen to keydown in order to let the user submit a comment if keyCode == 13.
Not sure ...
2
votes
1answer
1k views
AngularJS The scope for dynamic content through $compile isn't attached to the controller scope
When I generate a new element through a string that has a directive (that's why I need to compile) and that directive generates an association with a variable in the controller scope through "=", the ...
-1
votes
1answer
585 views
AngularJS how to pass data from one controller to different directives [closed]
I am not sure whether I can do like this or there is a better way. I need someone to guide me.
I created two template using directive (both directives in the same page).
Let say
directiveVideo for ...