Tagged Questions
0
votes
3answers
30 views
Dynamically specify the controller to use in an Angular directive
I am looking to specify the controller that a directive should use via an attribute on the element - i.e. dynamically:
HTML
<div data-mydirective data-ctrl="DynController"></div>
...
1
vote
1answer
30 views
Directive does not have access to controller function (AngularJS)
When I declare a directive to use that accesses a controller function, it cannot find the controller.
Here is my directive declared in app.js:
app.directive("delete", function() {
return {
...
3
votes
4answers
125 views
How to update a form controller in AngularJS after changing input constraints
I have been recently working on dynamically changing constraints on input fields on a form. The aim was to make a back-end-driven form, whereas all fields and their constraints are being sent to us by ...
0
votes
1answer
37 views
ng-repeat, ng-click, directive, and controller interaction
I have this directive snippet:
return {
scope: {},
restrict: 'E',
templateUrl: 'partials/order_table.html',
controller: 'OrderController as x',
link : ...
0
votes
1answer
17 views
Directives not loading in order when navigating between pages that reuse directives
I have a two separate pages that use the same controller.
I'm using ui router states to change between pages.
They contain the following directives which use templateUrl for templates in order:
Page A
...
0
votes
1answer
33 views
Modify elements based on data from ng-repeat
So i've just started learning Angular JS and i'm having troubles to do something that should be really simple but I can't figure out how to do it. Here's my problem...
I have a Array of objects from ...
0
votes
1answer
42 views
Update directive variable from controller
New to AngularJS I have a simple directive, service and controller. I loop through a list of items from a database in the controller embedded in the directive to render a checkbox list of items. From ...
0
votes
1answer
74 views
Sharing a controller scope between two directives with isolate scopes in AngularJS
I have two directives that provide different views on the same set of data. Both of these directives need to rely on central functionality contained in a controller. The controller uses various ...
1
vote
1answer
44 views
AngularJS directive using another controller
I'm trying to create a directive that will output a HTML-template that is using data from a controller.
In sample.js I've added a module, controller and directive
var app = angular.module("myApp", ...
0
votes
1answer
47 views
Where to put in logic for manually adding and removing classes for an anchor tag - Angular JS
I have a main html page in which I have an anchor tag (looks like a button explained below), a drop down with some values and a check box. Code is given below.
I have an anchor tag that makes it ...
0
votes
2answers
143 views
AngularJs Directives Loaded Event
I have just started using AngularJs directives, using the resources here, here and here.
I have a situation where i need to do something after all directives have been loaded.
i.e
Scenario 1
...
0
votes
1answer
46 views
angularjs app design multiple instances of the same component (directive or directive+controller)
My app needs to have multiple instances of a component that manages a complex model.
to display the model and the UI/DOM logic including a template with child directives I'v created a directive,
the ...
0
votes
2answers
57 views
Send Object From Directive to Parent Controller in AngularJS
How can I send an object back from a directive into the parent controller?
I've defined the following directive:
app.directive('inspectorSharedObjects', function () {
return {
restrict: 'E',
...
0
votes
1answer
76 views
Unknown provider: bProvider <- b
I have an AngularJS project with Directives and Controllers. After a while i got this error when I tried to run it:
Error: [$injector:unpr] Unknown provider: bProvider <- b
I have googled it and ...
0
votes
1answer
50 views
Call controller method from directive
I have a button which change the "active" state. First, it loads the status from the server
<button active="data.active" ng-click="changeStatus()"></button>
directive code:
...
0
votes
2answers
29 views
AngularJS accessing an attribute in a directive from a controller
I need to pass an Id defined in the directive to the associated controller such that it can be used in a HTTP Get to retrieve some data.
The code works correctly in its current state however when ...
2
votes
1answer
139 views
How do I assign an attribute to ng-controller in a directive's template in AngularJS?
I have a custom attribute directive (i.e., restrict: "A") and I want to pass two expressions (using {{...}}) into the directive as attributes. I want to pass these attributes into the directive's ...
0
votes
1answer
30 views
AngularJS Directive or Service?
My current understanding of AngularJS tells me that Directives should only contain DOM Manipulation and Services everything which has to do with logic and data handling.
In my case I'm unsure which ...
0
votes
1answer
17 views
Angularjs Error: registerService.getRegisterResponse is not a function
Error: registerService.getRegisterResponse is not a function
I getting Above Error on console of the web browser. While Accessing the a method(i.e saveRegisterResponse()) from Controller (i.e ...
1
vote
2answers
121 views
ng-repeat inserting empty anchor tags
I'm trying to create a menu using angular. A menu item can have children requiring another ng-repeat to print the sub nav items. I'm noticing some strange behavior when attempting to insert an anchor ...
0
votes
1answer
76 views
AngularJS: Directive to Controller communication with scope.apply not working
I have a MainController and a nested Directive. I'm looking at this example to see how the communication works between controllers and directive, but mine doesn't seems to work.
Basically, I want to ...
0
votes
1answer
196 views
How to pass $scope data between two partial files in angularjs
How can I pass data in two partial html files using angularJS, totally weird cant get through it.
I have one index file [fine.], I login and reach view5 [partials/blog.html] which is written in ...
0
votes
2answers
34 views
how to fire a controller method from another controller or directive?
What I need is to show some values automatically when I process some data on another controller, but how can I fire my $scope.setOnController1 function on controller1 when the controller2 have ended ...
0
votes
0answers
149 views
Angularjs initialize multiple controllers at startup?
i have a normal navbar with a menuController, this is the parent.
then i have two other controllers a DashBoardController this is loaded on startup and a LoadDataController this is called if i click ...
0
votes
1answer
66 views
How to override a controller function in an angular.js plugin
While developing my first Angular.js project I ran into troble. After a day-long research I have no idea how to override a plugin controller method.
I am using a pretty nice ...
0
votes
1answer
43 views
How do I create a directive with a controller in a way where the scope will work without having to use $parent in the view?
I need to include a controller as an attribute of my-modal. In my example, showModal is not in scope unless I use $parent.showModal = false. I can't use $parent in the view for the sake of other ...
-1
votes
1answer
39 views
Angularjs HTML compilation in Controller
I am facing a small problem during the compilation of html code in angularjs. Here is the brief description of my problem :
$scope.report= reportdata;
reportdata is the html code that contains ...
1
vote
1answer
67 views
AngularJS Directive to Controller communication with “Controller as …” syntax
I'm using the "Controller as" syntax and am in a situation where I'd like the Directive to communicate with the Controller.
I can get this to work when I do NOT use the "Controller as" syntax. ...
1
vote
1answer
29 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
128 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
72 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
85 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
74 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
44 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
98 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
169 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
593 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
2answers
244 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 ...
0
votes
2answers
235 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
437 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
33 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
38 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
117 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 ...
1
vote
0answers
595 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
24 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
108 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
54 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
78 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
165 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) {
...